在Notepad ++中使用RegEx删除/替换两个连续模式的多个实例

时间:2018-07-10 19:34:38

标签: regex notepad++

下面是示例文本。

Header
This is test, and
mid line adsf
bag a lot of many things
shoes>
shoes/
This line should not be affected.
Neither this line.
This is test, and
mid line
bag a lot of many things
shoes>
shoes/
Footer

需要替换/删除文本以This is test开始并以

结尾的行
shoes>
shoes/

使用Notepad ++ 7.5

RegEx的新手,以下是我的试用,未能选择多个实例。

(This is test).*(shoes/)
^This is test.*shoes/$

预期输出为

Header
This line should not be affected.
Neither this line.
Footer

1 个答案:

答案 0 :(得分:1)

^This is test((.|\n|\r)*?)shoes/$应该匹配;它考虑了换行符。编辑:根据{Wiktor的评论,^This is test(?s:.*?)shoes/$会更短和更好。