The camel is walking on water.
The cow jumped over the fence
The dog couldn't jump over the fence
The chicken flew over the ocean
The rabbit ate the elephant
The goat is singing like a bird
The dog barks like a woman
我有一个很长的列表,我需要删除上面的两行,如果我找到单词" dog"连续。所以最终的结果应该是
The dog couldn't jump over the fence
The chicken flew over the ocean
The dog barks like a woman
请让我知道如何完成这件事:)谢谢!!
答案 0 :(得分:0)
The camel is walking on water.
The cow jumped over the fence
The dog couldn't jump over the fence
The chicken flew over the ocean
The rabbit ate the elephant
The goat is singing like a bird
The dog barks like a woman
查找内容:.*\r\n.*\r\n(.*dog.*)
替换为:\1
The dog couldn't jump over the fence
The chicken flew over the ocean
The dog barks like a woman
.*
匹配任何字符 - 零到无限次(换行除外)
\r\n
一起代表换行符
(.*dog.*)
表示包含“dog”的行,整行被捕获到\1
在找到3条这样的线条之后,然后用包含狗的线替换所有三条线。
注意:这将删除包含“dog”的任何行上方的两行,即使其中一行本身包含“dog”