python string findall letters code example
Example 1: 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 2: regex findall
import re
# regex for finding mentions in a tweet
regex = r"(?<!RT\s)@\S+"
tweet = '@tony I am so over @got and @sarah is dead to me.'
# mentions = ['@tony', '@got', '@sarah']
mentions = re.findall(regex, tweet)