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?
shouldn't match when there is only one 'b2' between start and end, but it does.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
IMO, the most robust solution is to use a parser (Parse::RecDescent) or multiple regexes.
|
|---|