xxxxxxxxxx
import re
s1 = "str with aaa"
s2 = "str without any of the patterns"
r = re.compile(r'(aaa|bbb|ccc)')
r.match(s1)
>> True
r.match(s2)
>> False
xxxxxxxxxx
import re
# define a regular expression pattern to match multiple words
pattern = re.compile(r'hello|world|python')
# search for the pattern in a string
text = 'Hello, world! I love Python.'
matches = pattern.findall(text)