← Back to challenges

Regex Series: String Contains at Least One Digit

PythonHardstringsregexvalidation

Instructions

Write a regular expression that matches a string if it contains at least one digit.

Examples

has_digit("c8") ➞ True

has_digit("23cc4") ➞ True

has_digit("abwekz") ➞ False

has_digit("sdfkxi") ➞ False

Notes

This challenge is designed to use RegEx only.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Convert Key, Values in a Dictionary to List