Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Humanized lists of numbers

by japhy (Canon)
on Jun 23, 2001 at 01:32 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2025-05-14 05:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.