Is it possible to use the same name in a group named regex in python? for example (?P<n>foo)|(?P<n>bar).
Use case: I am trying to capture typeand iduse this regular expression
/(?=videos)((?P<type>videos)/(?P<id>\d+))|(?P<type>\w+)/?(?P<v>v)?/?(?P<id>\d+)?
of these lines:
- / channel / rev / 123
- / h / r / 41500082
- /channel
- / video / 41500082
At the moment, I am getting the error:
redefinition of group name 'id' as group 6; was group 3
source
share