... my $num1 = qr{^ (?> ([\.\d]+) ) (??{$1 == '1' ? '(?!)' : '' }) }x; my $txt1 = qr{^ (?> ([\.\d]+) ) (??{$1 eq '1' ? '(?!)' : '' }) }x; my @stuff = qw' 0101 1 123 1.1 01 222 21 1.000 '; print map $_ . "\t as num: " . (/$num1/ ? 'ok' : '--') . "\t as txt: " . (/$txt1/ ? 'ok' : '--') . "\n", @stuff; ...