Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Exclude word from search filter

    Help wanted · · · – – – · · ·
    2
    2
    382
    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 loftin
      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

      PeterJones 1 Reply Last reply Reply Quote 0
      • PeterJones
        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
        Copyright © 2014 NodeBB Forums | Contributors