[英]How to remove all the lines between two patterns in notepad++?
I'm trying to replace the below text我正在尝试替换以下文本
"{print next
error
incorrect
err
}end"
to至
"{print }end"
any I'm using (\{print)(.*?)(\}end)
but not working.任何我正在使用(\{print)(.*?)(\}end)
但不工作。 Deleting everything from print and end will also work从print和end中删除所有内容也可以
You could use你可以使用
\{print\h+\K[^{}]*\R(?=}end)
Explanation解释
\{
Match {
\{
匹配{
print\h+
match print and 1+ horizontal whitespace chars print\h+
匹配打印和 1+ 个水平空白字符\K
Forget wat is matched so far \K
忘记 wat 到目前为止是匹配的[^{}]*\R
Match 0+ times any char except {
or }
and a newline [^{}]*\R
匹配除{
或}
和换行符以外的任何字符 0+ 次(?=}end)
Positive lookahead, assert what is on the right is }end
(?=}end)
正向前瞻,断言右边是}end
In the replacement use an empty string.在替换中使用空字符串。
I'm getting familiar day by day to Regex usage, so here I share my approach....我越来越熟悉正则表达式的使用,所以在这里我分享我的方法....
Find what: next[\s\S]+?(?=})
查找内容: next[\s\S]+?(?=})
Replace with: nothing
替换为: nothing
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.