Understanding negation

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
pieter1
Posts: 4
Joined: Sat Jan 30, 2010 6:51 pm

Understanding negation

Post 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
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Understanding negation

Post 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.
pieter1
Posts: 4
Joined: Sat Jan 30, 2010 6:51 pm

Re: Understanding negation

Post 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
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Understanding negation

Post by DataMystic Support »

Glad we could help Pieter!
Post Reply