I want to remove single line breaks in my text but not double ones.
I'm able to replace lines using \r\n
. How can I remove single line breaks?
EDIT: I also need to add space before each line. For example if original text is:
line1
line2
line3
it must be converted to:
line1 line2 line3
If I've got your point - you need to convert single \r\n
to space but leave double, triple and so on.
You can use replace function of Notepad++ and this regular expression
(?<!\r\n)\r\n(?!\r\n)
Here we have negative lookbehind of \r\n
, then \r\n
itself and then negative lookahead of \r\n
, so it matches single occurence of \r\n
having no predecessors and no successors of the same characters.
Something like:
Note: you have to check "Regular expression" radiobutton at the bottom of form. Also field "replace with" should contain single space character.
As a result it converts following text:
line1
line2
line3
line4
line5
into this one:
line1 line2 line3
line4 line5
You can try to use CTRL + A and then CTRL + J
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With