python regex find all matches code example
Example 1: find all regex matches python
matches = re.findall(r"xxx|yyy", a_string)
Example 2: python .findall
match = re.search(r'bb', 'aabbcc')
match = re.search(r'cd', 'aabbcc')
match = re.search(r'...c', 'aabbcc')
match = re.search(r'\d\d\d', 'p123g')
match = re.search(r'\w\w\w', '@@abcd!!')
Example 3: python find multiple matches in string
a_string = "A string is more than its parts!"
matches = ["more", "wholesome", "milk"]
if any(x in a_string for x in matches):