http://qs1969.pair.com?node_id=90876


in reply to Humanized lists of numbers

I wrote a regex for Perl 5.6 that does this. It can be modified easily for letters:
sub list2range { local $_ = join ',' => @_; s/(\w+)(?:,((??{''.++(my$x=$+)})))+/$1-$+/g; return $_; }


japhy -- Perl and Regex Hacker