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

Re^3: Need a regex..

by kennethk (Abbot)
on May 21, 2012 at 14:33 UTC ( #971627=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Need a regex..
in thread Need a regex..

Please wrap code it <code> tags to keep things legible. As you can see, your character classes got linkified.

1234 is passing because it's being read as (123)(4). You should set the whole part following and including the decimal in a non-capturing group with a conditional: /^[-+]?[0-9]{0,3}(?:\.[0-9]{0,3})?%?$/ I've also removed a bunch of unnecessary escaping, and changed your {0,1} to the shorter ? synonym.

A read through of perlretut may be helpful.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2016-06-26 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (328 votes). Check out past polls.