如何删除记事本++中两个模式之间的所有线条?

How to remove all the lines between two patterns in notepad++?

我正在尝试替换下面的文字

"{print next
error
incorrect
err
}end"

"{print }end"

any 我正在使用 (\{print)(.*?)(\}end) 但无法正常工作。删除 printend 中的所有内容也将起作用

你可以使用

\{print\h+\K[^{}]*\R(?=}end)

说明

  • \{ 匹配 {
  • print\h+ 匹配打印和 1+ 个水平空白字符
  • \K忘记wat目前匹配
  • [^{}]*\R 匹配 0+ 次除 {} 和换行符之外的任何字符
  • (?=}end) 正面前瞻,断言右边是}end

Regex demo

在替换中使用空字符串。

我对正则表达式的使用越来越熟悉,所以在这里分享我的方法....

查找内容:next[\s\S]+?(?=})
替换为:nothing