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


in reply to Re: Can't match negated words.
in thread Can't match negated words.

Regexes match from left to right. So, if you first say "match /*", and then say, "don't match throw", it's *not* going to exclude "/*"'s that are preceeded with "throw". In fact, you haven't given any requirements for what should preceed "/*".

Ignoring the fact that you don't specify what should happen on a line like this:

/* throw /*
you might want to use something like:
m!^(?:(?!throw).)*/[*]!s
although that can probably be optimized (and the more you know about where you are going to match against, the more possibilities for optimizing there are).

Abigail