Search:

Web
This site only

How to delete certain lines in a file

In this example we delete all lines in a file that start with some predefined characters, like "xyz".

The edit rules we add:

1. Find regular expression "^xyz.*?^"
Here we search for the beginning of a line "^", followed by "xyz", possibly followed by some more characters ".*?", followed by the beginning of the next line "^".
The notation ".*?" is a "non-greedy" repeat which will match the smallest possible amount of input (as opposed to the normal repeat ".*" which will match as much input as possible).

2. Replace the whole match by the empty text. This will delete the matched line.

Two edit rules mentioned above will transform the text
Line 1
Some text here...
xyz - Here is the line to be deleted
more text...
xyz - one more to delete
last line of the file
into
Line 1
Some text here...
more text...
last line of the file
Privacy Statement