How to use regex to move just one line in notepad ++

I am trying to figure out how to use Regex to merge the contents of a text file

(25 data lines) in one line.

So far, I can get Notepad ++ to successfully find the strings I'm looking for by running a search (^) , but I'm not sure if this is what to replace.

Syntax. I am looking for the right script that essentially sticks the beginning of one line to the end of the previous one. Can anyone help? Thanks

+7
merge regex notepad ++ lines
source share
4 answers

Find \R and replace with an empty string.

\R matches several line styles, including the most common \r\n and \n .

Search mode must be set to regular expression.

+16
source share
  • Select the lines you want to join (or use Ctrl + A to select all)
  • Choose "Edit" → "Operations with the line" → "Connecting lines" in the menu or press Ctrl + J.

If necessary, it automatically places spaces to prevent words from getting stuck.

Alternatively you can

press Ctrl + H

In Search Mode select Extended

Find - \r\n Replace - leave it blank.

+5
source share

^ is an anchor , which means that it does not match characters (it matches the position after \n , or the beginning of a line). Therefore, nothing can be replaced.

If you need to use a regular expression (the response to the sound signal sounds good => +1), then

  [\n\r]+ 

and replace with anything or space to suit your needs.

+2
source share

You can replace

 [\r\n]+ 

with an empty string (or replace \n+ if you know your newline characters \n )

0
source share

All Articles