A
aspineux
I want to parse
'foo@bare' or '<foot@bar>' and get the email address foo@bar
the regex is
r'<\w+@\w+>|\w+@\w+'
now, I want to give it a name
r'<(?P<email>\w+@\w+)>|(?P<email>\w+@\w+)'
sre_constants.error: redefinition of group name 'email' as group 2;
was group 1
BUT because I use a | , I will get only one group named 'email' !
Any comment ?
PS: I know the solution for this case is to use r'(?P<lt><)?(?P<email>
\w+@\w+)(?(lt)>)'
'foo@bare' or '<foot@bar>' and get the email address foo@bar
the regex is
r'<\w+@\w+>|\w+@\w+'
now, I want to give it a name
r'<(?P<email>\w+@\w+)>|(?P<email>\w+@\w+)'
sre_constants.error: redefinition of group name 'email' as group 2;
was group 1
BUT because I use a | , I will get only one group named 'email' !
Any comment ?
PS: I know the solution for this case is to use r'(?P<lt><)?(?P<email>
\w+@\w+)(?(lt)>)'