简体   繁体   English

Notepad ++ Regex Ending With

[英]Notepad++ Regex Ending With

I want to remove all the lines until some terminating string. 我想删除所有行,直到一些终止字符串。 So something like this : 所以像这样:

These
lines 
  || that can contain numbers 123 or characters like |*{
will be removed
But the following lines
will 
remain.

I want to obtain : 我想获得:

But the following lines
will 
remain.

I tried searching the regexp /removed$/ and replacing with an empty string, but it says 0 matches . 我尝试搜索regexp /removed$/并替换为空字符串,但它表示0 matches

How can I do this? 我怎样才能做到这一点?

Thanks for any help ! 谢谢你的帮助 !

Make sure you check ". matches newline", and use .*removed\\.$ : 确保选中“。匹配换行符”,然后使用.*removed\\.$

Notice that you need .* at the start to match everything up until the terminating string, and you have to escape the literal . 请注意,您需要.*在开始时匹配所有内容直到终止字符串,并且您必须转义文字. at the end. 在末尾。

Also, Notepad++ doesn't want slashes around its regexes. 此外,Notepad ++不希望它的正则表达式斜杠。

If you don't have the . 如果你没有. at the end of your terminator, just remove the \\. 在终结器的末尾,只需删除\\. from the regex. 来自正则表达式。

To remove the trailing newline as well, you could use .*removed\\r?\\n? 要删除尾随换行符,也可以使用.*removed\\r?\\n? .

截图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM