• Login
Community
  • Login

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

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
find in files
4 Posts 3 Posters 39.8k 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.
  • P
    Peter Cohen
    last edited by Sep 8, 2017, 9:07 PM

    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
    • M
      Meta Chuh moderator
      last edited by Sep 8, 2017, 10:50 PM

      @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
      • P
        Peter Cohen
        last edited by Sep 8, 2017, 11:26 PM

        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
        • A
          AdrianHHH
          last edited by AdrianHHH Sep 11, 2017, 7:47 AM Sep 11, 2017, 7:46 AM

          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
          2 out of 4
          • First post
            2/4
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors