Community
    • Login

    Does notepad++ support a "find not" function?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    find in files
    4 Posts 3 Posters 39.5k 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.
    • Peter CohenP
      Peter Cohen
      last edited by

      Let’s say I have a LARGE file with many records with the same or similar content.
      Is there a way to look for records which do NOT contain that content?
      Example - File with the following records:

      • list itemThis record has the word something in it
        This record also has the word something in it
        This record contains different context
        This final record contains the word something again

      I want to find the record without the word “something” in it.
      Is there something like “find [not] something” ?

      1 Reply Last reply Reply Quote 0
      • Meta ChuhM
        Meta Chuh moderator
        last edited by

        @Peter-Cohen
        yes,
        you can find and/or replace any lines/records which do not contain a certain string using regular expressions.

        example:
        to find all lines which do not contain the string “pluto once was a planet” select regular expression as search mode in the notepad++ find or replace window
        then use following regex search string to find all lines which do not contain the string:

        ^(?!.*pluto once was a planet)(.*?)$
        

        btw:
        regex looks complicated at first, but normally you only have to modify the string part in templates like this one.

        once gotten used to it it’s quite cool, because we can automatically search and replace almost anything, even if it is as complicated as “if a line or part between 1 and 2 contains abc, but not def, except if ghi is found, then replace the string part between 1 and 2 or the string part between beginning and end of the line with xyz”

        1 Reply Last reply Reply Quote 1
        • Peter CohenP
          Peter Cohen
          last edited by

          Holy Cow - looking at that expression there is a good reason Pluto is not a planet anymore :-(.
          Guess I’ll have to read up on regex - thanks for your response.

          1 Reply Last reply Reply Quote 0
          • AdrianHHHA
            AdrianHHH
            last edited by AdrianHHH

            You could use the “Mark” tab in the search and replace dialogue. Have Bookmark line ticked. Search for the lines that have the string, then use menu => Search => Bookmark => Inverse bookmark**. Now the lines that do not match the search string are bookmarked. The Bookmark menu has several other commands for manipulating the (un)marked lines.

            1 Reply Last reply Reply Quote 1
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors