4

I want to delete all lines which contains the word "False"

For example, if I have a Textfile that contains the following :

Before

MyEmail@gmx.net|J|1983>2012>3000|Good|[0=%]
MyEmail@hotmail.net|N|1985>2012>3000|False|[~~~'#'***+++~~~]
MyEmail@hotmail.net|N|1985>2012>3000|Good|[$"$!]|Number 2123

After

MyEmail@gmx.net|J|1983>2012>3000|Good|[0=%]
MyEmail@hotmail.net|N|1985>2012>3000|Good|[$"$!]|Number 2123

Which regex I should use in Notepad++ to delete the unwanted lines?

logi-kal
  • 7,107
  • 6
  • 31
  • 43
Eule2000
  • 51
  • 1
  • 1
  • 2

4 Answers4

14

The last version of Notepad++ (v6.0) supports PCRE, so you can do:

search for : .*?False.*\r?\n
replace by : nothing

Toto
  • 89,455
  • 62
  • 89
  • 125
5

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.

1

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.

user123444555621
  • 148,182
  • 27
  • 114
  • 126
1

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.

Kevin Coffey
  • 386
  • 1
  • 6