• Login
Community
  • Login

Subtractive searching.

Scheduled Pinned Locked Moved General Discussion
3 Posts 2 Posters 421 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.
  • S
    Steve Hajdu
    last edited by Nov 19, 2021, 7:31 PM

    I’m looking for a way to perform the following when using notepad++ to search logs.

    Lets say I open a log and am searching for the word DELETE, now from those results I wish to exclude any lines with the word SYSTEM. Is there an easy way to do this?

    My current workaround is to search for the term I want. Copy the results into a new page, search for the term I don’t want, bookmark those lines, then remove the bookmarked lines. While this method works, it’s extremely tedious.

    I’ve tried looking for ways to do this with regex but I’m terrible at it. Any suggestions would greatly help.

    Thanks!!

    P 1 Reply Last reply Nov 19, 2021, 7:48 PM Reply Quote 0
    • P
      PeterJones @Steve Hajdu
      last edited by Nov 19, 2021, 7:48 PM

      @steve-hajdu ,

      What you want are lookahead expressions – positive for the match, and negative for the do-not-match.

      (?-s)^(?=.*\bDELETE\b)(?!.*\bSYSTEM\b).*$ will match lines that contain DELETE but do not contain SYSTEM, in either order, possibly with text between

      23539891-0df4-4f7c-a937-7ae073f31a1d-image.png

      I used a positive lookahead to match anything followed by the whole word DELETE, and a negative lookahead to exclude anything that matches anything followed by the whole word SYSTEM. I then do the .*$ at the end to make it select the whole line that contains DELETE without SYSTEM

      S 1 Reply Last reply Nov 20, 2021, 6:56 PM Reply Quote 3
      • S
        Steve Hajdu @PeterJones
        last edited by Nov 20, 2021, 6:56 PM

        @peterjones

        This is great, thank you very much

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