简体   繁体   English

记事本++中的正则表达式 - 在记事本++中删除“$”字符后的换行符“\\n”

[英]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 ++?如何使用 Notepad ++ 中的 Regex 搜索选项在每个美元符号后删除此换行符?

Update on Bohemians answer:波西米亚人答案的更新:

在此处输入图片说明

You would need to escape the $ :您需要转义$

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

Without escaping, $ means "end of line".没有转义, $表示“行尾”。

That's what worked for me.这就是对我有用的东西。

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

the Replace is not empty, it's one space stroke [space] Replace 不是空的,它是一个空格[space] 在此处输入图片说明

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字符将为您提供所需的结果。

(?<=\$)\n

If you want to remove one or more newline characters present just after to $ then add a + after \\n in your regex.如果您想删除$之后的一个或多个换行符,请在正则表达式中的\\n之后添加一个+

(?<=\$)\n+

Use the below regex if you want to remove one or more new line or carriage return characters.如果要删除一个或多个换行符或回车符,请使用以下正则表达式。

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

DEMO演示

Use the Extended mode , not Regular Expresssion and you can do:使用Extended mode ,而不是Regular Expresssion ,你可以:

Find what: $\\n查找内容: $\\n
Replace with: $替换为: $

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM