Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
yes-no RE pattern swap
#2
(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.
Reply


Messages In This Thread
yes-no RE pattern swap - by bluefrog - Jun-07-2018, 10:00 PM
RE: yes-no RE pattern swap - by volcano63 - Jun-08-2018, 07:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to swap two numbers in fields in python Joni_Engr 5 1,904 Jan-11-2022, 09:43 AM
Last Post: menator01
  Swap key and value of a dictionary - and sort it Omid 4 2,873 Oct-28-2020, 01:24 PM
Last Post: Omid
  swap elements in list hshivaraj 3 12,574 Apr-22-2019, 09:23 AM
Last Post: Yoriz
  I am trying to swap two variables with a Function.... Jeff_Waldrop 4 3,133 Mar-04-2019, 10:19 AM
Last Post: Jeff_Waldrop
  Randomise network while maintaining topology of nodes using edge-swap approach Tom1988 3 4,160 May-25-2017, 10:59 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020