I have two variables that are the result of regex searches.
a = re.search('some regex', str)
b = re.search('different regex', str)
This should return a re object. If they are not None, I want to use the group() method to get the string that it matched. This is the code I am using right now to do this:
if a != None:
a = a.group()
if b != None:
b = b.group()
Is there a more clever way to write these two if-statements? Maybe combine them into one? I think taking up 4 lines to do this is too verbose.
Thanks.