Hi
I have a problem that I do not know how to solve.
I need to compact a list of zip codes that can be in as only digits or mixed with letters and "-" or spaces signes.
I need to compact it to contain standalone zip, or range zips.
Here is an example of what I have and what I need to get from it:

Source: AB10 1AA,AB10 1AB,AB10 1AF,AB10 1AG,AB10 1AH,AB10 1AJ
Results needed: AB10 1AA-AB10 1AB,AB10 1AF-AB10 1AG,AB10 1AH,AB10 1AJ

or (Only digits)
Source: 0001,0002,0003,0005
Results needed: 0001-0003,0005

If its only digits then I just compare numbers, that's easy but I have no idea how to do it for a complex mixed string like in example no. 1.
Any help will be very helpful.
Thanks