in reply to Re: Keeping lookahead assertion from looking to the end of the string?
in thread Keeping lookahead assertion from looking to the end of the string?

Doesn't always work:

my $str = "start b2 end start b2 end start b2 end"; #only one b2 between each start and end if ($str =~ /.*start((.*?b2.*?b2).*?)end/) { print "$1\n"; } __END__ Output: b2 end start b2
shouldn't match when there is only one 'b2' between start and end, but it does.

IMO, the most robust solution is to use a parser (Parse::RecDescent) or multiple regexes.

  • Comment on Re: Re: Keeping lookahead assertion from looking to the end of the string?
  • Download Code