in reply to Matching text between tags

Can't test ( being mobile) but where is the loop? Did you post the whole code?

Please try replacing if with while .

edit

Or use list context @underlined= $text =~ //gs

Btw the /s will help . matching newlines.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^2: Matching text between tags
by Anonymous Monk on Apr 14, 2016 at 15:57 UTC
    Sorry, it matches, but only the first <u>...</u> There are two lines in the sample text.
    foreach my $lines (@lines){ if( $lines =~ /<u>(.*?)<\/u>/igs ){ print "\n $1\n"; } }
      Did you try what I suggested?

      if has scalar context and will only match once per line!

      The /g will only memorize the position fur the consecutive match.

      (i.e. two ifs will match twice and so on)

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!