Ds301222 #what we learned today

Regular Expression: A RegEx, or Regular Expression, is a sequence of characters that forms a search pattern. Python has a built-in package called re , which can be used to work with Regular Expressions.

Example-

import re
txt = “The rain in Spain”
x = re.search(“^The.*Spain$”, txt)

if x:
print(“YES! We have a match!”)
else:
print(“No match”)

OUTPUT-
YES! We have a match!

2 Likes

Keep practicing @vaishu.swap10112016

1 Like