Teresa
Teresa

Reputation: 13

Notepad++ join line not starting with | character with the previous line

I need to do import a large file with almost 50 columns and thousand of lines, with the struture |field|;|field|;|field|... Each field is started and ended with | (pipe) and ; (semicolon) to separate between fields

The problem is that some data have "Enters" in the middle and is "destroying" the lines

|123|;|ABC|;|text

text text|

|124|;|ABB|;|Text

text |

|125|;|BDD|;|text text text|

|126|;|ABC|;|text text

text

text|

|127|;|ABC|;|text text text|

I need if the line does not start with | (pipe) to delete the previous "enter" so line does't break

The expected result would be

|123|;|ABC|;|text text text|

|124|;|ABB|;|Text text |

|125|;|BDD|;|text text text|

|126|;|ABC|;|text text text text|

|127|;|ABC|;|text text text|

I have tried several suggestions the other questions but with no success so far. I never used this

Upvotes: 1

Views: 364

Answers (1)

The fourth bird
The fourth bird

Reputation: 163567

You could use match 0+ horizontal whitespace chars, a newline and 0+ whitespace chars using \h*\R\s*.

Then capture in group 1 any char except a whitespace char or pipe using ([^\s|])

In the replacement, use a space and group 1.

Find what:

\h*\R\s*([^\s|])

Replace with:

$1

Regex demo

enter image description here

Upvotes: 1

Related Questions