When working with text data, you often need to check whether a specific word appears in a given text. The Python function below provides a simple way to do this using regular expressions:
import re
def word_in_text(word, text):
word = word.lower()
text = text.lower()
match = re.search(word, text)
if match:
return True
return False
Top comments (0)