File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
0004-Regular-Expressions-Match Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 8
8
import re
9
9
10
10
# 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 ' )
12
12
RESULT = re .match (r'Hello' , 'Hello World' )
13
13
print (bool (RESULT )) # Output: True
14
14
15
15
# 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 ' )
17
17
RESULT = re .match (r'World' , 'Hello World' )
18
18
print (bool (RESULT )) # Output: False
19
19
20
20
# Using ^ to Match the Start
21
21
print ('Using ^ to Match the Start' )
22
+ print ('Checking if the word starts with H' )
22
23
RESULT = re .match (r'^H' , 'Hello World' )
23
24
print (bool (RESULT )) # Output: True
24
25
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
You can’t perform that action at this time.
0 commit comments