Perl regex issue , last character truncated -
have strange issue regex.
my regex truncating last character , in example below should return value 32 instead returning 3.
note value 10 digits!!!
$word = "thisisit="; $line = "hello thisisit=32 byefornow "; if ($line =~ m/$word(.*?)\d /) { print $1; #returns 3 instead of 32 } thanks.
you can do:
if ($line =~ /$word(\d+)/) # capture numbers after $word { print $1; } you can refine to:
if ($line =~ /$word\s*(\d+)/) # in case you're having "thisisit= 32 byefornow" or, capture , stop after first white space:
if ($line =~ /$word(.+?)\s/) { print $1; }
Comments
Post a Comment