Skip to content

Commit

Permalink
Fix for W1401: Anomalous backslash in string: '\d'. String constant m…
Browse files Browse the repository at this point in the history
…ight be missing an r prefix. (anomalous-backslash-in-string)
  • Loading branch information
oneananda committed Oct 24, 2024
1 parent 954edf9 commit 9a73792
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion 0005-Regular-Expressions-Search/regex_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
RESULT = re.search(r'cat|dog|parrot', 'I have a zebra')
print(bool(RESULT)) # Output: False

print('Slash \d : Matches any digit (equivalent to [0-9])')
print(r'\d : Matches any digit (equivalent to [0-9])')
# Adding 'r' before the string as it contains backword slash d '\d'

RESULT = re.search(r'\d', 'Hello 123')
print(bool(RESULT)) # Output: True
Expand Down

0 comments on commit 9a73792

Please sign in to comment.