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

skeptamistic
Posts: 4
Joined: Thu Mar 22, 2018 8:32 pm

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

Post by skeptamistic » Thu Oct 01, 2020 2:28 am

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

adrian
Posts: 2701
Joined: Tue May 17, 2005 4:01 pm

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

Post by adrian » Thu Oct 01, 2020 12:57 pm

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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

skeptamistic
Posts: 4
Joined: Thu Mar 22, 2018 8:32 pm

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

Post by skeptamistic » Fri Oct 02, 2020 1:10 am

@Adrian,

Thanks!

Best regards,

Post Reply