简体   繁体   English

Notepad++ 正则表达式在 XML 中找到与某个值不匹配的结果

[英]Notepad++ regex find results in XML that does not match a certain value

I am trying to search from the point of a certain parent tag inside the XML and see if a child tag inside this parent tag does not have a certain value.我正在尝试从 XML 内的某个父标签的位置进行搜索,并查看该父标签内的子标签是否没有特定值。 For example you have this:例如你有这个:

<situation xsi:type="..." id="TYU_A3213132343">
        ....
        <probability>likely</probability>
        .....
</situation>

If I want to search this with this value by probability I can use this:如果我想通过概率搜索这个值,我可以使用这个:

<situation xsi:type="([^\"]*)\" id="TYU_A(?:(?!</situation>).)+<probability>likely</probability>

But I want to change this regex so it find things like this:但我想改变这个正则表达式,让它找到这样的东西:

<situation xsi:type="..." id="TYU_A3213132343">
        ....
        <probability>randomvalue</probability>
        .....
</situation>

So I am searching for the results that does not match the probability with the value likely.所以我正在寻找与概率值不匹配的结果。 Does someone know what needs to be changed about the regex above?有人知道上面的正则表达式需要改变什么吗?

Just change likely with (?:(??likely)(.!</probability>).)+ that matches everything that is not likely before it reaches </probability> :只需使用(?:(??likely)(.!</probability>).)+ likely ,它匹配所有在到达</probability>之前不太likely的内容:

<situation xsi:type="([^\"]*)\" id="TYU_A(?:(?!</situation>).)+<probability>(?:(?!likely)(?!</probability>).)+</probability>

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

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