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

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -