繁体   English   中英

正则表达式在 Java 中跨多行的 2 个其他单词之间查找单词而不是其他单词

[英]Regex to find word and not other word between 2 other words across multiple lines in Java

我需要搜索多个 xhtml 文档以查找以下内容:任何有字符串action=但没有字符串update=我正在使用 Eclipse 搜索的标签,所以我需要 Java 格式的正则表达式

如果我没记错,这可以通过以下方式实现(我也忽略action/update=之间的空格)

^(?!.*update\s*=).*action\s*=.*$

我的问题是这样的单行搜索是不够的,因为 html 标签可能跨越多行。

所以,我需要在标签的<>之间查看,即使在不同的行上。

那能实现吗?

我想匹配的示例行(我不在乎该部分是否被忽略:

<a href="#" action="test" update="test_container"></a>

<a href="#" action="test2"
 update="test_container2"></a>

<mytag href="#" update="test_container3"
action="test3" />

action= ,但不是update=里面<...>

<([^>](?!update\s*=))*action\s*=([^>](?!update\s*=))*>

暂无
暂无

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

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