In this we are going to see a basic program to find string or word from a sentence in Python Programming Language.
import re
patterns = [ 'fox', 'dog', 'horse' ]
text = 'The quick brown fox jumps over the lazy dog.'
for pattern in patterns:
print(f'Searching for "{pattern}" in -> "{text}"')
if re.search(pattern, text):
print('Matched!')
else:
print('Not Matched!')
# Code By DHIRAJ SHELKE
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP