![]() |
|
XP is just a number | |
PerlMonks |
Re: Check for Positive Integer entry onlyby kyle (Abbot) |
on May 09, 2007 at 17:33 UTC ( #614458=note: print w/replies, xml ) | Need Help?? |
You might want to look at Regexp::Common::number in general, but I don't see anything ready-made to do what you want. Here's a pattern I might use:
Using Regexp::Common, that might be:
If you want to allow for white space in your data entry, you could add \s* into your patterns. Update: After consideration of the contributions of the other monks, I think this is a better expression than the one I have above:
This incorporates Nkuvu's observation that a value of zero should not be allowed and mreece's suggestion that \d is not always the best way to match digits (though I find this counterintuitive). It also passes my own test suite.
In Section
Seekers of Perl Wisdom
|
|