(Jun-07-2018, 10:00 PM)bluefrog Wrote: I then verify whether there has in fact been a match by specifying ?(1).
I suggest that you test your RE on https://regex101.com/ - besides testing, it also provides you with a full explanation of your RE structure.
I think that your problem - over-complication of the RE. It works just fine with a little simplification -
(\d\d-\w{1,2}|\w{1,2}-\d\d)
Not that it is the case here, but numbered groups may get tricky in nested expressions - named group may be a better idea.
Test everything in a Python shell (iPython, Azure Notebook, etc.)
- Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
- Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
- You posted a claim that something you did not test works? Be prepared to eat your hat.