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
Comment on Re: How do I match a expression start with $a and not contain $b after $a