In this we are going to see a basic program to check if a sentence contains z not at starting nor at the end using regular expression in Python Programming Language.
import re
pattern = "\w*z\w*"
sen1 = "The Home Is Filled With Lazy Boys"
sen2 = "Help For Coders"
def text_match(text):
if re.search(pattern, text):
return 'Found a match!'
else:
return('Not matched!')
x1 = text_match(sen1)
x2 = text_match(sen2)
print(x1)
print(x2)
# Coded By DHIRAJ SHELKE
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP