Skip to content

Commit

Permalink
Matching with Optional Characters (?), Matching Alphanumeric Strings
Browse files Browse the repository at this point in the history
  • Loading branch information
oneananda committed Oct 22, 2024
1 parent 2a2311f commit a3259bf
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions 0004-Regular-Expressions-Match/regex_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,10 @@
RESULT = re.match(r'\w{6}', 'abcde12345')
print(result.group()) # Output: 'abcde1'

print('Matching with Optional Characters (?)')
RESULT = re.match(r'colou?r', 'color')
print(result.group()) # Output: True

print('Matching Alphanumeric Strings')
RESULT = re.match(r'[A-Za-z0-9]+', 'Python123!')
print(result.group()) # Output: Python123

0 comments on commit a3259bf

Please sign in to comment.