I am trying to change the order using regex, but running into a problem with alternative groups.
Example: 1a,1b,1c ABC
Output: ABC*1a,ABC*1b,ABC*1c
Example: 1a,2b ABC
Output: ABC*1a,ABC*2b
Example: 1a ABC
Output: ABC*1a
So far what I have is:
re.sub(r'((\d\W,\d\W,\d\W)|(\d\W,\d\W)|(\d\W))()(\d\W\d\W\d\W)',r'\3\*\1',string)
Any ideas on how to deal with the possible subgroups?