in reply to Re: Need to match number other than 1
in thread Need to match number other than 1
You don't have to generate any code. The (?(COND)TRUE|FALSE) assertion fits the glove here. $^N can be used instead of $1 here, making it copy-paste safe.
I'd also like to draw some attention to Regexp::Common::number. These changes would make
becomemy $num1 = qr{^ (?> ([\.\d]+) ) (??{$1 == '1' ? '(?!)' : '' }) }x;
I reversed the logic in the COND block so that it reads better to me. "Match a number, the number isn't 1, done".use Regexp::Common qw/ number /; my $num1 = qr{^ (?> ($RE{num}{dec}) ) (?(?{ $^N != '1' })|(?!)) }x;
lodin
|
|---|