How do I remove single line breaks?

2019-08-14 12:39发布

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

2条回答
在下西门庆
2楼-- · 2019-08-14 12:51

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
查看更多
\"骚年 ilove
3楼-- · 2019-08-14 12:56

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

查看更多
登录 后发表回答