Reputation: 49
I want to delete all lines which contains the word "False"
For example, if I have a Textfile that contains the following :
Before
[email protected]|J|1983>2012>3000|Good|[0=%]
[email protected]|N|1985>2012>3000|False|[~~~'#'***+++~~~]
[email protected]|N|1985>2012>3000|Good|[$"$!]|Number 2123
After
[email protected]|J|1983>2012>3000|Good|[0=%]
[email protected]|N|1985>2012>3000|Good|[$"$!]|Number 2123
Which regex I should use in Notepad++ to delete the unwanted lines?
Upvotes: 3
Views: 10379
Reputation: 91375
The last version of Notepad++ (v6.0) supports PCRE, so you can do:
search for : .*?False.*\r?\n
replace by : nothing
Upvotes: 14
Reputation: 386
You can't do it with a regex in a single step, but using bookmarks there is a two step process.
In the Find dialog there is an option to 'Bookmark line' which can be used, among other things, to flag lines matching your query for deletion. In newer versions of Notepad++ this has been moved to the 'Mark' tab the Find dialog.
Once the desired lines have been bookmarked, from the menu bar select Search > Bookmark > Remove Bookmarked Lines. As the name implies, this will remove all lines flagged in the previous search.
Upvotes: 1
Reputation: 152956
You can't. Notepad++ does not support mixing RegExps with line ends
Removing the end of line, or joining the lines, can be done in extended mode only.
,
The "Extended" option shows \n and \r as characters that could be matched. As with the Normal search mode, Notepad++ is looking for the exact character.
Upvotes: 1
Reputation:
Its probably as simple as going into the Notepad++ tools menu and enterring the text to search for then stipulate to delete each line it finds it in.
Otherwise a normal regex to identify the entire line might be something like this -
redo
If the default is (.) dot as anything but newline, then this
.*False.*\n?
else, this
[^\n]*False[^\n]*\n?
These should match an entire line (plus a newline) if 'False' is on the line.
Anything more like 'False' has to be surrounded by delimiters is extra logic.
Upvotes: 5