Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove single line breaks?

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
like image 884
onurcano Avatar asked Oct 16 '15 12:10

onurcano


2 Answers

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: enter image description here

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
like image 192
Andrey Korneyev Avatar answered Nov 15 '22 04:11

Andrey Korneyev


You can try to use CTRL + A and then CTRL + J

like image 33
Rahul Tripathi Avatar answered Nov 15 '22 05:11

Rahul Tripathi