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


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

Try
/a(?!b)/
with negative lookahead.

And yes, your regexp looks rather OK, except I would drop a few \b anchors:

/a\b|a[^b]/
or combined:
/a(\b|[^b])/
Will that do?

Replies are listed 'Best First'.
Re^2: Find all strings containing "a" characters, that are not followed by "b" characters.
by Anonymous Monk on Dec 12, 2012 at 18:04 UTC
    immediately after, and anywhere after, not the same :)