in reply to How do I match a expression start with $a and not contain $b after $a

It's easier to split up the task and use two regexes:     /$a/ && !/$a.*?$b/s; If you still very much want to have it in one regex you can use     /^(?>.*?$a)(?!.*?$b)/s; but that not compatible with perl 5.004 or earlier. (You can rewrite it to be compatible with perl 5.004, but I'll leave that as an exercise for you. Hint: look in the perlre manpage.)

-Anomo

Replies are listed 'Best First'.
Re: Re: How do I match a expression start with $a and not contain $b after $a
by Anonymous Monk on Jan 29, 2002 at 06:33 UTC
    I just noticed that it's not totally clear whether 'xfoobar' should match or not with $a = 'foo' and $b = 'bar'.

    -Anomo