Match lines that don't contain any of the specified strings.
-
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. -
@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.
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
-
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).)*
-
@Terry-R
Thankyou, “bookmarking” got it to work for me.