I am trying code a regular expression which will capture an "unsigned fixed decimal" value, preserving the original formatting. Here is what I'm trying to do:
When I run this I get the following:my $decimal = qr(\d*\.?\d+); $_ = "0.12"; if ( m{(?<value> $decimal)}x ) { say "$_ $+{value}"; } $_ = ".12"; if ( m{(?<value> $decimal)}x ) { say "$_ $+{value}"; } $_ = "12."; if ( m{(?<value> $decimal)}x ) { say "$_ $+{value}"; } $_ = "12"; if ( m{(?<value> $decimal)}x ) { say "$_ $+{value}"; }
0.12 0.12 .12 .12 12. 12 12 12
But the third line, I am not preserving the trailing decimal place, although the values should be equal.
Can anyone point out how I could change my "qr" so that it "works" for the third line?
In reply to regex to capture an unsigned decimal value, but also preserving the user's formatting. by darisler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |