Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Humanized lists of numbers

by japhy (Canon)
on Jun 23, 2001 at 01:32 UTC ( #90876=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://90876]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2023-01-29 19:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?