I have found two ways to extract matches in Python:
1.
def extract_matches(regexp, text):
matches = re.match(regexp, text)
if matches:
return matches.group(1)
2.
def extract_matches(regexp, text):
try:
return re.findall(regexp, text)[0]
except IndexError:
return None
Which one would you suggest me to use? And do you know any other ways to do this?
Thanks, Boda Cydo.