Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex: Remove lines containing "help", etc

I have a long document of commands. Using Notepad++ or regex, I want to delete all lines containing "help" including keyboard_help, etc.

How can this be done?

like image 838
dukevin Avatar asked May 03 '11 22:05

dukevin


People also ask

How do you replace a complete line in Notepad++?

This method is very powerful as you can match almost anything (such as words “beginning with”, or lines that have a specific “pattern”.) Open the text-based file using Notepad++. Press Ctrl + F to open the Find and Replace dialog. Click the Replace tab to select it.

How do you remove text before or after a specific character in Notepad++?

Do you want to delete everything before the | and including the | character. You can try find: (. +\|) and leave replace empty.


2 Answers

This is also possible with Notepad++:

  • Go to the search menu, Ctrl + F, and open the Mark tab.
  • Check Bookmark line (if there is no Mark tab update to the current version).

  • Enter your search term and click Mark All

    • All lines containing the search term are bookmarked.
  • Now go to the menu SearchBookmarkRemove Bookmarked lines

  • Done.

like image 70
stema Avatar answered Oct 24 '22 20:10

stema


Another way to do this in Notepad++ is all in the Find/Replace dialog and with regex:

  • 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.

  • Make sure the Regular expression radio button in the Search Mode area is selected. Then click Replace All and voila! All lines containing your search term help have been removed.

How-To Line Replace in N++

like image 231
OozeMeister Avatar answered Oct 24 '22 21:10

OozeMeister