Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Welcome to the Monastery
 
PerlMonks

Re: Humanized lists of numbers

by japhy (Canon)
 | Log in | Create a new user | The Monastery Gates | Super Search | 
 | Seekers of Perl Wisdom | Meditations | PerlMonks Discussion | 
 | Obfuscation | Reviews | Cool Uses For Perl | Perl News | Q&A | Tutorials | 
 | Poetry | Recent Threads | Newest Nodes | Donate | What's New | 

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


Comment on Re: Humanized lists of numbers
Download Code
Login:
Password
remember me
What's my password?
Create A New User

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 contemplating the Monastery: (25)
BrowserUk
GrandFather
jdporter
wfsp
johngg
atcroft
mr_mischief
kennethk
herveus
MidLifeXis
Marshall
rowdog
psini
SFLEX
jkva
ssandv
DStaal
wwe
AndyZaft
Neighbour
dxxd116
DarthWavy
graghave
ldbpm
im2
As of 2010-09-02 15:08 GMT
Sections?
Seekers of Perl Wisdom
Cool Uses for Perl
Meditations
PerlMonks Discussion
Categorized Q&A
Tutorials
Obfuscated Code
Perl Poetry
Perl News
See About the sections of PerlMonks
Information?
PerlMonks FAQ
Guide to the Monastery
What's New at PerlMonks
Voting/Experience System
Tutorials
Reviews
Library
Perl FAQs
Other Info Sources
Find Nodes?
Nodes You Wrote
Super Search
List Nodes By Users
Newest Nodes
Recently Active Threads
Selected Best Nodes
Best Nodes
Worst Nodes
Saints in our Book
Leftovers?
The St. Larry Wall Shrine
Offering Plate
Awards
Craft
Snippets Section
Code Catacombs
Quests
Editor Requests
Buy PerlMonks Gear
PerlMonks Merchandise
Planet Perl
Perlsphere
Use Perl
Perl.com
Perl 5 Wiki
Perl Jobs
Perl Mongers
Perl Directory
Perl documentation
CPAN
Random Node
Voting Booth?

My favourite poll on PerlMonks is ...

Your first Perl Book - the first one ever
Average number of caffeinated beverages per work day - the poll with the highest participation
My Thoughts on the New Voting/Experience System - the poll with the fewest votes cast
When I grow up, I want to be: - one of the polls with the fewest options
Perl 6 will primarily be: - the first one on Perl6
When I see a poll - one of the many polls about polls
this poll ;-)
yet to come
none - I hate polls. Bah.
some other

Results (49 votes), past polls