I'm trying to execute this lines of code:
my $test = 'test .15oz test';
$test =~ /([\d]+)([\.]?[\d]+)*oz\b/;
print("test=$1\n");
The output of this is:
test=15
I want to catch that dot. What am I doing wrong? The best would be to catch 0.15 somehow, but for now I can't even get a dot.
Any help with getting 0.15 from regex would be appreciated, so:
0.15 -> 0.15
.15 -> 0.15
..15 -> 0.15
0.0.0.15 -> 0.15
000.15 -> 0.15
15 -> 15
I tried also:
$test =~ /([\d]+)(\.?[\d]+)*oz\b/;
$test =~ /([\d]+)([.]?[\d]+)*oz\b/;
but with no success. Still getting "15" :/
\.or[.](there are other flavors of regexes that might fail when presented with superfluous backslash escapes, so it's best to avoid it). Anyway, that's not the problem here. – blubberdiblub Jan 19 at 18:11$test =~ /(\d*\.?\d+)oz\b/;– Wiktor Stribiżew Jan 19 at 18:21