开发者

How do I use regex to replace a sentence with paragraphs in Notepad++?

开发者 https://www.devze.com 2023-02-27 03:40 出处:网络
I\'m a Notepad++ newbie and I have a report with multiple instances of this sentence All students with a C grade and below will not be allowed to join any outdoor trip.

I'm a Notepad++ newbie and I have a report with multiple instances of this sentence

All students with a C grade and below will not be allowed to join any outdoor trip.

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. 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.


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. This is to motivate weaker students.\n\n(Please contact us if you feel this is harsh).

and choose search mode Extended, that should do the trick


Ctrl + H

Search for:

All students with a C grade and below will not be allowed to join any outdoor trip.

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).

And make sure youe search modus is on extended


Notepad++ Regex can't handle rowbreaks very well. But in your case you should not use Regex, but 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. This is to motivate weaker students.\n\n(Please contact us if you feel this is harsh)

0

精彩评论

暂无评论...
验证码 换一张
取 消