http://www.perlmonks.org?node_id=1008611


in reply to Re: Find all strings containing "a" characters, that are not followed by "b" characters.
in thread Find all strings containing "a" characters, that are not followed by "b" characters.

A look-ahead is fine, you just have to insert .* (zero or more of anything) before the "b" I think.

$ perl -E ' > say qq{$_ - @{ [ m{a(?!.*b)} ? q{Match} : q{No match} ] }} for ( > q{Have you any fish}, > q{What a nice broom}, > q{Fishing for trout}, > );' Have you any fish - Match What a nice broom - No match Fishing for trout - No match $

I hope this is of interest.

Cheers,

JohnGG