Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Matching an integer between 0 and 100

by JavaFan (Canon)
on Sep 01, 2009 at 15:49 UTC ( #792693=note: print w/ replies, xml ) Need Help??


in reply to Matching an integer between 0 and 100

First of all, I would never ever combine \d and hardcoded numbers. Your regexp will match 0 to 99 in more than a dozen scripts, but 100 only in western numerals.

Given that, I'd write it as /^(?:[0-9]{1,2}|100)$/. Or, if I wanted to be lazy: do {local $" = "|"; /^(?:@{[0..100]})$/};.


Comment on Re: Matching an integer between 0 and 100
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2015-07-02 05:02 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 (27 votes), past polls