in reply to Re^2: regex to capture an unsigned decimal value, but also preserve the user's formatting.
in thread regex to capture an unsigned decimal value, but also preserving the user's formatting.
I think the other important point to make is that the order of the sub-patterns in the ordered alternation is critical:
(See '56.' and '-54.' instances.)c:\@Work\Perl\monks>perl -wMstrict -le "my $ufp = qr{ \d* [.]? \d+ | \d+ [.]? \d* }xms; ;; for my $s (qw(0.12 .34 56. 78)) { printf qq{'$s' -> }; printf qq{'$1' \n} if $s =~ m{ ($ufp) }xms; } ;; my $s = '0.12 -0.98 .34 -.76 56. -54. 78 -32 bla bla abc.def42 .7zx'; printf qq{'$1' } while $s =~ m{ ($ufp) }xmsg; " '0.12' -> '0.12' '.34' -> '.34' '56.' -> '56' '78' -> '78' '0.12' '0.98' '.34' '.76' '56' '54' '78' '32' '42' '.7'
Give a man a fish: <%-{-{-{-<
|
|---|