I want to search a document for the following string
<whoName>[substring]</whoName>
where substring != "self"
so
<whoName>other</whoName>
would pass.
but
<whoName>self</whoName>
would fail
I want to search a document for the following string
<whoName>[substring]</whoName>
where substring != "self"
so
<whoName>other</whoName>
would pass.
but
<whoName>self</whoName>
would fail
You can use this negative lookahead based regex:
<(whoName)>(?!self\s*<).*?<\/\1>
Regex breakup:
<(whoName)> # Match <whoName> and capture it ($1)
(?!self\s*<) # Negative lookahead that means current position is not followed by literal
# self followed by 0 or more spaces and <
.*? # Match 0 or more characters (non-greedy)
<\/\1> # Match closing tag using back-reference to captured group #1
Use this regex:
^<whoName>((?!self<).)*</whoName>
Tested in notepad++ and regex101
You can find the solution here.
You could use something like
<whoName>(?!self)[a-z0-9]*<\/whoName>
(try this out here: https://regex101.com/r/vW8sP3/1).
As you can imagine the relevant part is (?!self)
.