简体   繁体   English

如何使用正则表达式在Notepad ++中用段落替换句子?

[英]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.

相关问题 如何替换notepad ++正则表达式中的以下内容? - How do i replace following in notepad++ regex? NOTEPAD ++ REGEX如何替换和删除$ 0中的空格 - NOTEPAD++ REGEX How do I replace and remove a whitespace from $0 如何使用正则表达式替换Notepad ++中的标记之间的文本 - How to use regex to replace text between tags in Notepad++ 如何在变量中存储正则表达式匹配以与Notepad ++中的“搜索/替换”一起使用 - How to store regex match in a variable to use with Search/Replace in Notepad++ Notepad ++和Regex:如何将大写句子转换为小写句子? - Notepad++ and Regex: How to convert a uppercase sentence in a lowercase sentence? Notepad ++正则表达式如何替换字符,但仅在双引号之间 - Notepad++ Regex how do I replace characters but only when between double quotes Notepad ++ Regex如何使用相同的值替换所找到的但前面有空格的内容? - Notepad++ Regex How do I replace what is found with the same value but with a space in front? 如何使用RegEx替换Notepad ++中的HTML代码 - How can I replace HTML code in Notepad++ using RegEx 如何在 Notepad++ 中用正则表达式替换此文本? - How can I replace this text with regex in Notepad++? 如何在记事本++中的正则表达式中使用正则表达式替换数字? - How can I use regex to replace numbers in my regular expressions inside notepad++?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM