Javier Salas
Javier Salas

Reputation: 139

How to remove line with certain pattern and append it to previous one | Notepad++

I have a CSV file with "|" delimeter but it has a bug and I want to correct it as a Hot Fix, before to get in the code, as it contains a lot of lines is hard to do it manually.

CSV example:

Michael|Cort
| 23
George|Dieter
| 25

As you can see the age is displayed in new line, but I want to remove it and put it like this:

Michael|Cort| 23
George|Dieter| 25

i used regex search with ^\|

Is this possible? if so, how could let notepad++ remove or backspace to append it to the previous line?

Thanks

Upvotes: 0

Views: 72

Answers (1)

Toto
Toto

Reputation: 91430

  • Ctrl+H
  • Find what: \R(\|)
  • Replace with: $1
  • check Wrap around
  • check Regular expression
  • Replace all

Explanation:

\R      : any kind of linebreak (ie. \r, \n, \r\n)
(\|)    : group 1, a pipe character

Replacement:

$1          : content of group 1 (i.e. pipe)

Result for given example:

Michael|Cort| 23
George|Dieter| 25

Upvotes: 1

Related Questions