- match() in a regular expression are used to match the pattern to the string.
Syntax-
re.match(pattern,string,flag=0)
program-
#import the re module
import re
#Given string is
s = "This is programming language"
x=re.match('This',s)
if x:
print("Matched")
else:
print("Not matched")
x=re.match('The',s)
if x:
print("Matched")
else:
print("Not matched")
Matched
Not matched