Understanding negation

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

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

Understanding negation

Postby pieter1 » Sun Nov 28, 2010 11:54 pm

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: 2164
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Understanding negation

Postby DataMystic Support » Tue Nov 30, 2010 8:32 am

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.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

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

Re: Understanding negation

Postby pieter1 » Tue Nov 30, 2010 8:57 pm

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: 2164
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Understanding negation

Postby DataMystic Support » Wed Dec 01, 2010 11:47 am

Glad we could help Pieter!
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: No registered users and 10 guests