# credit to Stack Overflow user in source link
import re
re.search(r'is', your_string)
# Step-By-Step breakdown:
import re # We need this module
# First make a regex object containing your regex search pattern. Replace REGEX_GOES_HERE with your regex search. Use either of these:
regex_obj = re.compile(r'REGEX_GOES_HERE', flags=re.IGNORECASE) # Case-insensitive search:
regex_obj = re.compile(r'REGEX_GOES_HERE') # Case-sensitive search
# Define the string you want to search inside:
search_txt = "These are oranges and apples and pears"
# Combine the two to find your result/s:
regex_obj.findall(search_txt)
#And it wrapped in print:
print(regex_obj.findall(search_txt)) # Will return a LIST of all matches. Will return empty list on no matches.
import re
s = "ABC12DEF3G56HIJ7"
pattern = re.compile(r'([A-Z]+)([0-9]+)')
for m in re.finditer(pattern, s):
print m.group(2), '*', m.group(1)