Regex 是否可以在UltraEdit中使用正则表达式跨换行匹配模式?

Regex 是否可以在UltraEdit中使用正则表达式跨换行匹配模式?,regex,text-editor,ultraedit,Regex,Text Editor,Ultraedit,UltraEdit文本编辑器包括用于搜索的Perl和Unix兼容正则表达式引擎 我希望能够匹配以下字符串行: <branch id="attribute"> <leaf id="attribute"/> <leaf id="attribute"/> <leaf id="attribute"/> </branch> 比如说: /<branch id="attribute">.*</branc

UltraEdit文本编辑器包括用于搜索的Perl和Unix兼容正则表达式引擎

我希望能够匹配以下字符串行:

<branch id="attribute">
    <leaf id="attribute"/>
    <leaf id="attribute"/>
    <leaf id="attribute"/>
</branch>

比如说:

/<branch id="attribute">.*</branch>/gis
/.*/gis
有没有一种方法可以使用UltraEdit来实现这一点?

如果在模式的开头放置(?s),它将启用单线模式,因此\r\n不会被排除在匹配之外*

例如,以下内容匹配整个分支元素(在UEStudio 6中使用Perl样式的正则表达式):

(?s)*
做一个小实验,还支持其他一些Perl选项。e、 g.(?sx-i)开头是单行,忽略模式中的额外空白,区分大小写(默认为不区分大小写)。

您尝试过:

/<branch id="attribute">[.\n]*</branch>/gis
/[.\n]*/gis

如果选择了Perl正则表达式,则可以执行以下操作:

<branch id="attribute">[\s\S]*</branch>
从答案中可以看出,在UltraEdit中有许多方法可以实现这一点


注意:使用UltraEdit 14.20进行测试。

他询问的是特定文本编辑器中的正则表达式语法,该编辑器不使用您显示的语法。此外,\n可能与Windows上使用的\r\n匹配,也可能不匹配,因此您需要使用[。\r\n]不仅仅是[。\n]我不知道UltraEdit是否像使用的OP一样支持/s修饰符,但是[\s\s]技巧也应该同样有效。加上非贪婪匹配的“?”,应该可以完全回答这个问题。谢谢。这对我有用。关于贪婪匹配的部分也很有用。
<branch id="attribute">[\s\S]*</branch>
<branch id="attribute">
  <leaf id="attribute"/>
  <leaf id="attribute"/>
  <leaf id="attribute"/>
</branch>
<branch id="attribute">
  <leaf id="attribute"/>
  <leaf id="attribute"/>
  <leaf id="attribute"/>
</branch>
<branch id="attribute">[\s\S]*?</branch>