Skip to content

Commit a3259bf

Browse files
committed
Matching with Optional Characters (?), Matching Alphanumeric Strings
1 parent 2a2311f commit a3259bf

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

0004-Regular-Expressions-Match/regex_match.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,10 @@
5151
RESULT = re.match(r'\w{6}', 'abcde12345')
5252
print(result.group()) # Output: 'abcde1'
5353

54+
print('Matching with Optional Characters (?)')
55+
RESULT = re.match(r'colou?r', 'color')
56+
print(result.group()) # Output: True
57+
58+
print('Matching Alphanumeric Strings')
59+
RESULT = re.match(r'[A-Za-z0-9]+', 'Python123!')
60+
print(result.group()) # Output: Python123

0 commit comments

Comments
 (0)