Reputation: 261
The Eclipse software has a functionality to search for regular expressions.
I'd like to search for all <version>0.0.1-SNAPSHOT</version>
strings whose xml parent node is not <parent>
.
What would be the easiest way to do that ?
Upvotes: 1
Views: 191
Reputation: 336448
Edit: Complete rewrite.
As long as <parent>
tags can't be nested, this is possible, but only then (and all the usual caveats about not trying to match XML with regexes apply. As soon as you have comments or CDATA sections in your XML, all bets are off).
(?s)<version>0\.0\.1-SNAPSHOT</version>(?!(?:(?!</?parent>).)*</parent>)
Explanation:
(?s) # Turn on singleline matching mode
<version>0\.0\.1-SNAPSHOT</version> # Match this string
(?! # but only do this if it's impossible to match this regex here:
(?: # Try to match...
(?!</?parent) # (as long as there is no <parent> or </parent> tag ahead)
. # any character
)* # any number of times
</parent> # Then match </parent>
) # End of lookahead
Upvotes: 1