Below is a code I am trying out (to learn regex myself).
a = "This island is beautiful"
reg = re.compile(r'\bis\b')
print(reg.match(a))
print(reg.findall(a))
print(reg.search(a).group(0))
The output of the code is
None
['is']
is
As you can see, findall
& search
found the word 'is' in the string but match
returns None
.
Shouldn't match
also find the word 'is'? I am confused.