goombaloon
goombaloon

Reputation: 3099

Regex to strings that end with a particular substring

I'm trying to use regex to find all instances of a word "foo" that doesn't end with ".bar".

For example:

foo foo1 foo.bar

In the example above, I want "foo" and "foo1", but not "foo.bar". Further, I'm looking to do this using the regex capabilities of Notepad++ and am unsure of the proper syntax.

Upvotes: 1

Views: 88

Answers (1)

edi_allen
edi_allen

Reputation: 1872

You can try this regex. It uses a negative lookahead to disallow the string foo from matching when followed by the string .bar.

\bfoo(?!\.bar)

Upvotes: 1

Related Questions