Community
    • Login

    Exclude word from search filter

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 2.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • kendall loftinK
      kendall loftin
      last edited by

      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

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @kendall loftin
        last edited by

        @kendall-loftin ,

        You can use negative lookbehinds to guarantee that “the text before house is not future and is not tech and is not bass”:

        • 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

        • Please Read Before Posting
        • Template for Search/Replace Questions
        • FAQ: Where to find regular expressions (regex) documentation
        • Notepad++ Online User Manual: Searching/Regex
        1 Reply Last reply Reply Quote 1
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors