search()
` function in Python's `re
` module to search a string for a pattern :import re
string = "The quick brown fox jumps over the lazy dog in Spain."
pattern = "fox"
match = re.search(pattern, string)
if match:
print("Found a match!")
else:
print("No match found.")
Found a match!
fox
". If the pattern is found, it will print "Found a match!
". If the pattern is not found, it will print "No match found
.".pattern
` variable to search for different patterns in the string.