re.findall code example
Example 1: find all regex matches python
matches = re.findall(r"xxx|yyy", a_string)
Example 2: python regex search group
>>> m = re.match(r"(\w+) (\w+)", "Isaac Newton, physicist")
>>> m[0]
'Isaac Newton'
>>> m[1]
'Isaac'
>>> m[2]
'Newton'
Example 3: searching for a pattern in text with re python
import re
xx = "guru99,education is fun"
r1 = re.findall(r"^\w+",xx)
print(r1)
Example 4: regex findall
import re
regex = r"(?<!RT\s)@\S+"
tweet = '@tony I am so over @got and @sarah is dead to me.'
mentions = re.findall(regex, tweet)
Example 5: python re compile
import re
prog = re.compile(pattern)
result = prog.match(string)
result = re.match(pattern, string)
Example 6: 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!!')