Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Need to match number other than 1

by moritz (Cardinal)
on Nov 29, 2007 at 10:28 UTC ( [id://653798]=note: print w/replies, xml ) Need Help??


in reply to Need to match number other than 1

m/\A (?: [1]\d+ # if it starts with a 1, # it has to be followed by other digits | [023456789]\d* # otherwise one digit can be fine ) \z /x

Note that this matches only non-negative integers, and 01 is matched as well (no idea if that's OK or not, spec is unclear).

Note that you need some kind of anchoring (perhaps to a word boundary), but you don't necessarily need to anchor it to start and beginning of the string.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-23 18:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found