Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How to consolidate regex's?

by samarzone (Pilgrim)
on Feb 05, 2010 at 13:58 UTC ( [id://821559]=note: print w/replies, xml ) Need Help??


in reply to How to consolidate regex's?

If you want to be very strict about the pattern of the string (including the comma).
perl -e '$a = "1,234,340 views";print "$1\n" if($a =~ /^((?:\d{1,3})?( +?:,\d{3})*) views$/);'
I think using "^" will speed up things a bit (although a few nanoseconds won't make much difference) when compared to similar regex without "^".

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-19 02:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found