Using RegEx in Notepad++ to delete all lines contain certain keywords?
NZ Select last edited by
I have a list of urls in a text file.
Each URL is one a new line
https://domain.com/dog.html https://domain.com/dog-2.html https://domain.com/cat.html https://domain.com/cat-2.html https://domain.com/fish.html https://domain.com/dolphin.html
I wish to know if there is a way to use RegEx to remove all lines that contain the word cat and fish?
So the list becomes below, which removed 3 lines matched
https://domain.com/dog.html https://domain.com/dog-2.html https://domain.com/fish.html
Terry R last edited by Terry R
to remove all lines that contain the word cat and fish?
I believe the following (given your example) should suffice.
Using the Replace function
Replace With: leave this field empty
This is a regex so search mode must be “regular expression” and have wrap around ticked.
I should mention this ONLY looks for those characters, so if the word cat or fish is part of a larger word it will still be removed. So
fishermanalso get removed.
Terry R last edited by
if the word cat or fish is part of a larger word it will still be removed
A slightly revised regex would be
This expects non word characters (boundaries) to exist around the words
cat-2is still caught.