Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find and replace end of line with "\n" verbatim

I am hoping to use some text editor to find all the "end of lines" in a document and replace them with just the written sequence "\n" (for ease of conversion into another file type). I've been trying with both Notepad++ and textpad with little luck.

When using regular expression mode on Notepad++ for example, I will type in [Find: \n] in the find field (which it will find successfully) and [Replace: \Q\n\E] in the replace field (the \Q and \E being verbatim search modifiers as far as I can tell), with no encouraging effects.

Is there an easy way do accomplish this replacement?

like image 919
jennifer.cl Avatar asked Mar 13 '13 23:03

jennifer.cl


2 Answers

In the notepad++ search & replace dialog (Ctrl-H), go into "Extended" mode.

From there, replacing \r\n with \\n should do it - if I understand your question correctly.

For instance, I typed in...

something
something else
blah

... and then did the above with "Replace All", which left me with:

something\nsomething else\nblah
like image 197
nitsua Avatar answered Sep 28 '22 10:09

nitsua


enter image description here

Open Find and Replace -> Find "$" and Replace With "Any Character". In Search Mode Select Regular Expression. Refer Image.

like image 38
Srijan Chaudhary Avatar answered Sep 28 '22 11:09

Srijan Chaudhary