Page 1 of 1

Understanding negation

Posted: Sun Nov 28, 2010 11:54 pm
by pieter1
I have an XML file from which I want to remove certain tagged elements EXCEPT those elements containing another specific tagged element.
For example:

Code: Select all

<LABEL>bla bla bla<SUBLABEL>blu blu blu</SUBLABEL>bla bla bla</LABEL>
So all Element:LABEL must be removed unless it contains the Element:SUBLABEL . I tried this with Remove Matching lines, but was not successful. What I read from the Helpfile(latest version 8.6.7) it is not possible to combine negated and non-negated characters. Is this correct? If not, how should I make the remove lines specification?
I can of course write some Jscript to achieve my goal, but a regexp would be more elegant. Thank you for your attention,
Pieter

Re: Understanding negation

Posted: Tue Nov 30, 2010 8:32 am
by DataMystic Support
Include/exclude only works at the character level - so append a single character to the SUBLABEL to make it easy to identify.

e.g. \xFF.

Find <SUBLABEL> - replace with <SUBLABEL>\xFF

Then, search for:
<LABEL>[^\xFF]*</LABEL>

Replace with nothing.

As the last step, replace \xFF with nothing.

Re: Understanding negation

Posted: Tue Nov 30, 2010 8:57 pm
by pieter1
I have given it a try, but could not get it to work on my version 7.6.3. So I installed the latest trial version 8.6.7 (which I ordered in the meantime) on my portable, where it ran as expected.
Thanks, Pieter

Re: Understanding negation

Posted: Wed Dec 01, 2010 11:47 am
by DataMystic Support
Glad we could help Pieter!