在Notepad ++中用它们中的某些文本替换整行

时间:2015-05-05 02:12:53

标签: replace notepad++ yaml

我正在编辑一个大的YAML文件,并且多次出现在文本中(用占位符替换了实际文本):

options:
- placeholder1!
- this is a placeholder!
- %placeholderhere%!
- placeholder
- you get the point by now
- more placeholders
- one last placeholder...
this is just some text don't replace
options:
- placeholder1!
- this is a placeholder!
- %placeholderhere%!
- placeholder
- you get the point by now
- more placeholders
- one last placeholder...

我想把它变成这个:

options:
- placeholder1!
this is just some text don't replace
options:
- placeholder1!

感谢您的帮助:)

1 个答案:

答案 0 :(得分:0)

输入

options:
- placeholder1!
- this is a placeholder!
- %placeholderhere%!
- placeholder
- you get the point by now
- more placeholders
- one last placeholder...
this is just some text don't replace
options:
- placeholder1!
- this is a placeholder!
- %placeholderhere%!
- placeholder
- you get the point by now
- more placeholders
- one last placeholder...

查找^options.*?- (placeholder1).*?placeholder...$
替换为-\1!

enter image description here

注意:不要忘记选中matches newline复选框(仅限v6.0)

结果:

-placeholder1!
this is just some text don't replace
-placeholder1!