DextrousDave
DextrousDave

Reputation: 6793

Regex in Notepad ++ - Remove the line break “\n” after a “$” character in Notepad++

I have a file containing many instances of block text that are $ separated. After each $ sign, there is a line break. How do I remove this line break after each dollar sign using the Regex search option in Notepad ++?

Update on Bohemians answer:

enter image description here

Upvotes: 6

Views: 33769

Answers (4)

Rami Alloush
Rami Alloush

Reputation: 2626

That's what worked for me.

Search: $[\n\r]+
Replace:  

the Replace is not empty, it's one space stroke [space] enter image description here

Upvotes: 4

Bohemian
Bohemian

Reputation: 425328

You would need to escape the $:

Search: \$[\n\r]+
Replace: $

Without escaping, $ means "end of line".

Upvotes: 5

Toto
Toto

Reputation: 91518

Use the Extended mode, not Regular Expresssion and you can do:

Find what: $\n
Replace with: $

Upvotes: 0

Avinash Raj
Avinash Raj

Reputation: 174836

Use a lookbehind to match all the newline characters which are next to the $ symbol. Replacing the matched \n characters with empty string will give you the desired result.

(?<=\$)\n

If you want to remove one or more newline characters present just after to $ then add a + after \n in your regex.

(?<=\$)\n+

Use the below regex if you want to remove one or more new line or carriage return characters.

(?<=\$)[\r\n]+

DEMO

Upvotes: 0

Related Questions