To see what is regular expression and how to use it in python3.
special sequence of characters that helps you match or find other strings or sets of strings.
The module re provides full support for regular expressions in python.
This function attempts to match RE pattern to string with optional flags.
This function searches for first occurrence of RE pattern within string with optional flags.
#Regular expression module
import re
#input string
string = “Python is a scripting language”;
#initialize match object
match = re.match( r’Pythons’, string, re.M|re.I)
if match:
print (“”, match.group())
else:
print (“No match”)
#initialize search object
search = re.search( r’Python’, string, re.M|re.I)
if search:
print (“Serach success “, search.group())
else:
print (“Nothing found”)