Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 记事本++;以结尾的正则表达式_Regex_Replace_Notepad++ - Fatal编程技术网

Regex 记事本++;以结尾的正则表达式

Regex 记事本++;以结尾的正则表达式,regex,replace,notepad++,Regex,Replace,Notepad++,我想删除所有行,直到出现终止字符串。比如说: These lines || that can contain numbers 123 or characters like |*{ will be removed But the following lines will remain. 我想获得: But the following lines will remain. 我尝试搜索regexp/removed$/并替换为空字符串,但它显示0匹配 我该怎么做 谢谢你的帮助 确保选中“.

我想删除所有行,直到出现终止字符串。比如说:

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

But the following lines
will 
remain.
我尝试搜索regexp
/removed$/
并替换为空字符串,但它显示
0匹配

我该怎么做

谢谢你的帮助

确保选中“.matches newline”,并使用
*removed\.$

请注意,您需要在开始时使用
*
匹配所有内容,直到终止字符串,并且必须在结束时转义文本

此外,Notepad++不希望在正则表达式周围使用斜杠

如果终止符末尾没有
,只需从正则表达式中删除
\.

要同时删除尾随的换行符,可以使用
*removed\r?\n?


一个“.”是一个特殊字符吗?试着用“\”把它挖出来,不要介意这个点。我把它拿走了。对不起。我的终止字符串实际上是一个带字母的字符串。谢谢!因此,如果终止字符串在没有点的情况下被“删除”,正则表达式会被。*删除$?再次感谢!几乎完美。不过有个小问题。它将第一行留空。所以带“但是”的一行变成了第二行,而不是第一行。但这没关系,所以我会接受你的回答(5分钟内)。如果你找到了这个问题的解决方案,请也发布。太好了!非常感谢:)