|Think about Loose Coupling|
Matching an integer between 0 and 100by McDarren (Abbot)
|on Sep 01, 2009 at 15:43 UTC||Need Help??|
McDarren has asked for the
wisdom of the Perl Monks concerning the following question:
This is just something that came up in a casual email exchange today. And I've no particular reason for posing the question here other than curiosity, and perhaps providing the opportunity for those with plenty of regex fu to show their stuff :)
"How would you construct a regex to match an integer between 0 and 100?"
My regex fu is only average at best, but after a couple of minutes I came up with:
Solves the "problem", but hard-coding the 100 in the pattern is pretty horrible, I think.
So how would others do this?