Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Help with regEX

by Codon (Friar)
on Sep 14, 2005 at 16:57 UTC ( #491927=note: print w/ replies, xml ) Need Help??


in reply to Help with regEX

Get rid of that substitution:

my ($digits) = $var =~ /([0-9]+)/;
And then you can use the "digit" metacharacter \d:
my ($digits) = $var =~ /(\d+)/;
For your learning pleasure: the reason your original regex failed is you were getting all characters that were not a lower-case letter in a greedy fasion. That sucked up the entire string with your first atom. There were no digits left to match. Might I suggest Mastering Regular Expressions for much more information.

Ivan Heffner
Sr. Software Engineer, DAS Lead
WhitePages.com, Inc.


Comment on Re: Help with regEX
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2015-07-06 00:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls