Exclude word from search filter
-
Hello,
I am using the Find feature of npp to find lines that have the word house in it, but I want to exclude versions of the word such as future house, tech house, and bass house.
What is the regular expression to search for lines containing house but also excluding the words future, tech, bass -
You can use negative lookbehinds to guarantee that “the text before
houseis notfutureand is nottechand is notbass”:- FIND =
(?:(?<!future )(?<!tech )(?<!bass ))house - Search Mode = Regular expression
You can combine that with your whole line matcher, which used to be something like
(?-s)^.*house.*$to become:- FIND =
(?-s)^.*(?:(?<!future )(?<!tech )(?<!bass ))house.*$
… that will then match the whole line, not just the individual “house” on that line
-—
Useful References
- FIND =
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login