Which fix removes the bug?
import re
if re.match(r'\d+', value):
accept(value)
- Anchor the whole value:
r'\d+$' - Anchor the whole value:
r'^\d+' - Change
re.matchtore.searchhere - Compile the pattern before matching it
match only anchors the start, so '12abc' is accepted; add $ to require the full string.
Play Problem Solving ▸