in reply to Looking for a flexible regex...

This not a regex solution, but perhaps Parse::Range can help you. You feed this module one or more ranges and it returns you a list of the items in these ranges.

use Modern::Perl; use Parse::Range qw(parse_range); say join ' ', sort {$a <=> $b} parse_range('1-2a,27,150b-170,51d2,670 +-675, 12, 90-97, 99-95');
Output:
12 27 90 91 92 93 94 95 96 97 98 99 670 671 672 673 674 675
It will warn you about non-numeric ranges:
non-numeric range: '1-2a' at c:/Data/strawberry/perl/site/lib/Parse/Ra +nge.pm line 54. non-numeric range: '150b-170' at c:/Data/strawberry/perl/site/lib/Pars +e/Range.pm line 54. non-numeric range: '51d2' at c:/Data/strawberry/perl/site/lib/Parse/Ra +nge.pm line 54.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics