Skip to content

Commit 95f34e1

Browse files
committed
Print messages for re.match function
1 parent 16d4bbc commit 95f34e1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

0004-Regular-Expressions-Match/regex_match.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,25 @@
88
import re
99

1010
# Match at the beginning of the string
11-
print('Match at the beginning of the string')
11+
print('Match at the beginning of the string wity Hello')
1212
RESULT = re.match(r'Hello', 'Hello World')
1313
print(bool(RESULT)) # Output: True
1414

1515
# No Match if not at the beginning of the string
16-
print('No Match if not at the beginning of the string')
16+
print('No Match if not at the beginning of the string with World')
1717
RESULT = re.match(r'World', 'Hello World')
1818
print(bool(RESULT)) # Output: False
1919

2020
# Using ^ to Match the Start
2121
print('Using ^ to Match the Start')
22+
print('Checking if the word starts with H')
2223
RESULT = re.match(r'^H', 'Hello World')
2324
print(bool(RESULT)) # Output: True
2425

26+
print('Checking if the word starts with He')
27+
RESULT = re.match(r'^He', 'Hello World')
28+
print(bool(RESULT)) # Output: True
29+
30+
print('Checking if the word starts with Hi')
31+
RESULT = re.match(r'^Hi', 'Hello World')
32+
print(bool(RESULT)) # Output: False

0 commit comments

Comments
 (0)