Using Visual Studio Code
In Visual Studio Code, to delete the entire line make your regex something like:
^.*(word1|word2).*\n?
In the above regular expression,
- ^ – Matches the beginning of line
- . – Matches any character (except newline character)
- * – Match 0 or more repetitions of the preceding character, as many repetitions as are possible. For example ab* will match ‘a’, ‘ab’, or ‘a’ followed by any number of ‘b’s.
- (…) – Matches whatever regular expression is inside the parentheses, and indicates the start and end of a group.
- | – A|B, where A and B can be arbitrary REs, creates a regular expression that will match either A or B.
- ? – Causes the resulting regular expression to match 0 or 1 repetitions of the preceding regular expression. ab? will match either ‘a’ or ‘ab’.
- \n – Linefeed character. On windows, use \r?\n instead of \n.
If you want to delete the entire line having word word1 and word2, follow below steps
- Press CTRL + F to open Find, and select the regular expression mode as shown below.
- Paste above string.
- Click on the right most bottom icon.
Using Notepad++
To replace the line, follow below steps
- Press CTRL + H to bring up the find replace dialog.
- In the Find what: text box include your regex: .*help.*\r?\n (where the \r is optional in case the file doesn’t have Windows line endings).
- Leave the Replace with: text box empty as shown in below figure.
- Make sure the Regular expression radio button in the Search Mode area is selected.
- Then click Replace All. All lines containing your search term help have been removed.