[Solved] Python regex to find digit in first n characters [closed]


This will do it in 1 shot, but not the way you’d expect:

r'\D{n}'

That is, it matches string of length n that does not contain any digits; thus, if the match fails, there must be a digit in the first n characters.

1

solved Python regex to find digit in first n characters [closed]