in reply to Match range of number
my ($min, $max) = (35, 50); if ( m/^(\d+)(??{ $^N >= $min && $^N <= $max ? '' : '(?!)'})$/ ){ print "$_ is between $min and $max\n"; }
This uses code assertions, see perlre for details.
Note that this example only works for integers (otherwise you'd have to adapt the regex, preferably with Regexp::Common.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Match range of number
by ikegami (Patriarch) on Nov 15, 2007 at 11:59 UTC | |
by moritz (Cardinal) on Nov 15, 2007 at 12:10 UTC |