I have a regex: (?<=>).*?(?=<)
which properly matches text from my html. It's probably simplified query but doesn't matter.
我有一个正则表达式:(?<=>)。*?(?= <)正确匹配我的html文本。它可能简化了查询,但并不重要。
My question is: how to modify this query to match all except some word?
我的问题是:如何修改此查询以匹配除了某些单词之外的所有内容?
What I'm trying to do is (?<=>).*?(?!ICMJE)(?=<)
to skip this word, but it doesn't work as many of my trials.
我想要做的是(?<=>)。*?(?!ICMJE)(?= <)跳过这个词,但它不能像我的许多试验那样起作用。
The html snippet looks like:
html代码段如下:
<th class="header3 banner_color" align="left" valign="top" width="15%">Intervention <sup style="color:blue"> ICMJE </sup>
</th>
Finally match should return only one "Intervention" word. Please help.
最后匹配应该只返回一个“干预”字样。请帮忙。
1 个解决方案
#1
2
You can use a negative look-ahead (?<=>)((?!ICMJE).)*(?=<)
你可以使用负面预测(?<=>)((?!ICMJE)。)*(?= <)
which will match anything except your string
除了你的字符串,它将匹配任何内容
(?<=>)((?!ICMJE).)*(?=<)
:
-
(?<=>)
: positive -look behind to match>
character -
((?!ICMJE).)
match anything till line-break exceptICMJE
-
(?=<)
positive look-ahead to match<
characterr
(?<=>):正面 - 后面匹配>字符
((?!ICMJE)。)匹配除ICMJE之外的任何内容
(?= <)正向前瞻以匹配
#1
2
You can use a negative look-ahead (?<=>)((?!ICMJE).)*(?=<)
你可以使用负面预测(?<=>)((?!ICMJE)。)*(?= <)
which will match anything except your string
除了你的字符串,它将匹配任何内容
(?<=>)((?!ICMJE).)*(?=<)
:
-
(?<=>)
: positive -look behind to match>
character -
((?!ICMJE).)
match anything till line-break exceptICMJE
-
(?=<)
positive look-ahead to match<
characterr
(?<=>):正面 - 后面匹配>字符
((?!ICMJE)。)匹配除ICMJE之外的任何内容
(?= <)正向前瞻以匹配