Community

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

    Match lines that don't contain any of the specified strings.

    General Discussion
    regex notepad++
    3
    4
    1280
    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.
    • Jadian Radiator
      Jadian Radiator last edited by

      I already know how to match lines not containing a singular string from this.
      However I can’t figure out how to make it work on multiple sub strings all at the same time.
      This is the list of strings I’m needing to regex search&replace through.
      I need to match everything except the lines beginning with either a hyphen, or the phrase “Mining Level:”
      This is a screenshot of the regex search patterns I’ve tried.
      Though some of the ones with “.+” have “. matches new line” turned on.

      Alan Kilborn 1 Reply Last reply Reply Quote 0
      • Terry R
        Terry R last edited by Terry R

        @Jadian-Radiator said in Match lines that don't contain any of the specified strings.:

        match lines not containing a singular string

        You might need to be more concise with what you need to do as you firstly state I need to match lines not containing (suggesting removing the whole line), but later you refer to the search and replace function suggesting ONLY portions of lines need editing/removing.

        I will show you a method of removing complete lines which don’t have specific strings in them. This uses the “Mark” function. As an example I copied your post and used “Mark” along with “bookmark lines” to mark those lines to KEEP.
        096a3cd6-e086-4ffb-955f-9532d7291e33-image.png
        As you will see I used 3 strings separated by the | character which is the “alternation” meta character. It allows for multiple searches to be carried out simultaneously. Although my strings were plain text you could use regular expressions, provided the search mode is set to “regular expression”.

        By running this multiple times (which I think you may need to do if the link you provided shows ALL strings to be searched) you can mark additional lines, until you have completed all the marking operations. Then you can remove “unmarked” lines by using the function “Remove Unmarked Lines” under Search, Bookmark.

        Additional to that we have you need to exclude lines starting with a hyphen or a particular string. As my Mark idea is actually the reverse of finding lines NOT containing strings, perhaps you could also do that with this additional request. Mark those using ^-|mining level.

        Hopefully this will help, otherwise you may need to elaborate.

        Terry

        Jadian Radiator 1 Reply Last reply Reply Quote 4
        • Alan Kilborn
          Alan Kilborn @Jadian Radiator last edited by

          @Jadian-Radiator

          I already know how to match lines not containing a singular string from this.
          I can’t figure out how to make it work on multiple sub strings all at the same time.

          So the basis of your situation is: (?!badword).)*

          Have you tried something like this?: (?!(badword1)|(badword2).)*

          1 Reply Last reply Reply Quote 2
          • Jadian Radiator
            Jadian Radiator @Terry R last edited by

            @Terry-R
            Thankyou, “bookmarking” got it to work for me.

            1 Reply Last reply Reply Quote 2
            • First post
              Last post
            Copyright © 2014 NodeBB Forums | Contributors