in reply to Delving the regexp underdark -- how to understand \G's behavior, or how to loop through a regular expression

s/\*\./.*/g
  • Comment on Re (tilly) 1: Delving the regexp underdark -- how to understand \G's behavior, or how to loop through a regular expression
  • Download Code

Replies are listed 'Best First'.
Re: Re (tilly) 1: Delving the regexp underdark -- how to understand \G's behavior, or how to loop through a regular expression
by boo_radley (Parson) on Feb 02, 2001 at 21:10 UTC
    whoops.
    the regexps ARE actually .*s. I was just too busy being witty to notice the typo.
      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"; }
      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.