in reply to Re: Re (tilly) 1: Delving the regexp underdark -- how to understand \G's behavior, or how to loop through a regular expression
in thread Delving the regexp underdark -- how to understand \G's behavior, or how to loop through a regular expression
Works perfectly well for me. Note that the s modifier that I added to the RE allows your extracted text to extend across multiple lines. I don't know if that will matter to you.use strict; my $text = <<EOT; foo this is one example bar this is a line I don't care about foo here's another keeper! bar foo yet another bar and a line to reject EOT while ($text =~/foo(.*?)bar/gs) { print "$1\n"; }
|
|---|