[英]How do I use regex to replace a sentence with paragraphs in Notepad++?
I'm a Notepad++ newbie and I have a report with multiple instances of this sentence 我是一名Notepad ++新手,并且有一份包含该句子多个实例的报告
All students with a C grade and below will not be allowed to join any outdoor trip.
所有C级及以下的学生均不得参加任何户外旅行。
I'd like to change the sentence to 我想将句子改为
Due to change in policy, students with a C grade and below will not be joining any trip.
由于政策上的变化,C级及以下的学生将不会参加任何旅行。 This is to motivate weaker students.
这是为了激励较弱的学生。
(Please contact us if you feel this is harsh).
(如果您觉得这很苛刻,请与我们联系)。
I'm confused on the usage of ()
and \\n
in this instance. 在这种情况下,我对
()
和\\n
的用法感到困惑。
You don't need a regex. 您不需要正则表达式。 Make the replace string :
制作替换字符串:
Due to change in policy, students with a C grade and below will not be joining any trip. 由于政策上的变化,C级及以下的学生将不会参加任何旅行。 This is to motivate weaker students.\\n\\n(Please contact us if you feel this is harsh).
这是为了激励较弱的学生。\\ n \\ n(如果您觉得这很苛刻,请与我们联系)。
and choose search mode Extended, that should do the trick 并选择“扩展”搜索模式,即可解决问题
Ctrl + H Ctrl + H
Search for: 搜索:
All students with a C grade and below will not be allowed to join any outdoor trip.
所有C级及以下的学生均不得参加任何户外旅行。
Replace with: 用。。。来代替:
Due to change in policy, students with a C grade and below will not be joining any trip.\\n This is to motivate weaker students.\\n\\n(Please contact us if you feel this is harsh).
由于政策上的变化,C级及以下的学生将不会参加任何旅行。\\ n这是为了激励较弱的学生。\\ n \\ n(如果您觉得这很苛刻,请与我们联系)。
And make sure youe search modus is on extended 并确保您的搜索方式已扩展
Notepad++ Regex can't handle rowbreaks very well. Notepad ++正则表达式不能很好地处理行中断。 But in your case you should not use Regex, but Extended.
但是在您的情况下,您不应使用Regex,而应使用Extended。
Choose Search - Replace and check Extended as Search mode. 选择搜索-替换,然后选中扩展为搜索模式。 Then replace the text with:
然后将文本替换为:
Due to change in policy, students with a C grade and below will not be joining any trip.
由于政策上的变化,C级及以下的学生将不会参加任何旅行。 This is to motivate weaker students.\\n\\n(Please contact us if you feel this is harsh)
这是为了激励较弱的学生。\\ n \\ n(如果您觉得这很苛刻,请与我们联系)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.