Page 1 of 1

Searching for PIs that do not have a particular word in the comment

Posted: Thu Oct 01, 2020 2:28 am
by skeptamistic
How do I search for processing instructions that do not have a specified word in the PI comment="" ?

Suppose the word is future.

In the find dialog in oXygen, when I activate regex and Enable XML search options > PIs, the following regex (unfortunately) matches a PI that includes comment="future: purpose-action":

Code: Select all

(?!.*future).*
I believe I can be better at regex. :D

Re: Searching for PIs that do not have a particular word in the comment

Posted: Thu Oct 01, 2020 12:57 pm
by adrian
Hello,

I'm afraid you can't use Enable XML search options > PIs for this situation. The problem is you need to match an entire PI that doesn't have "future" in it, not just parts of it. So for this you would need ^ (region beginning) and $ (region end). However, Oxygen interprets these as line start and line end, so they can't be used with XML search options (they won't provide a match).

Without "Enable XML search options" try the following regular expression (this matches entire PIs):

Code: Select all

(?<=<\?)((?!future).)*?(?=\?>)
Regards,
Adrian

Re: Searching for PIs that do not have a particular word in the comment

Posted: Fri Oct 02, 2020 1:10 am
by skeptamistic
@Adrian,

Thanks!

Best regards,