I'm learning RegEx in Python 3 and using parenthesis to extract groups is giving me an unexpected behavior that I couldn't find explained anywhere.
This is the code:
str = '<b>bold</b>'
match = re.search(r'>(\w+?)<', str)
match.group() == '>bold<'
I've tried the following variations
match = re.search(r'>(.+?)<', str)
match = re.search(r'>(.+)<', str)
match = re.search(r'>(,)<', str)
match = re.search(r'>([\w]+)<', str)
and they all return the same string. As far as I know it should just return 'bold'. Can someone explain what am I doing wrong?
Thank you!