Exclude option from search in files

Are you missing a feature? Request its implementation here.
gilles_charon
Posts: 3
Joined: Fri Feb 02, 2018 12:41 pm

Exclude option from search in files

Post by gilles_charon »

Hi,
I often need to search files which not contain a specific text or pattern.
It would be usefull to have an exclude option in the "search/replace in files" interface
Regards
Gilles
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Exclude option from search in files

Post by adrian »

Hi,

Other than Linux/Unix command line tools (grep, ack), I haven't seen a tool (especially GUI tool) that supports an exclude string (files without match) search.
Anyway, I've logged a feature request for such an option on our issue tracking tool.

Meanwhile, for XML files you could use an XPath 3.0 (or XQuery 3.0) expression in the XPath/XQuery Builder view to locate such files that do not contain a specific string:

Code: Select all

for $x in collection('file:/path/to/my/folder?select=*.xml')[not(contains(unparsed-text(base-uri()),'exclude_string'))]
return $x
Replace exclude_string with whatever text the files should not contain.
This isn't really lightweight, but it should work. Do note that this can only be used on well-formed XML files.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
gilles_charon
Posts: 3
Joined: Fri Feb 02, 2018 12:41 pm

Re: Exclude option from search in files

Post by gilles_charon »

Hello,
Thank you for your reply.
I've tried this with an element name -> [not (descendant::element)]
Not very practical, but it works.
Just a curious thing : search runs endless and every file goes out many times, always increasing...
Regards
Gilles
Radu
Posts: 9434
Joined: Fri Jul 09, 2004 5:18 pm

Re: Exclude option from search in files

Post by Radu »

Hi Gilles,

About this remark:
search runs endless and every file goes out many times, always increasing...
The "Scope" of the XPath should be "Current File" because the XPath itself looks recursively in all files inside a certain folder.
If you set its scope to some other file set, for each file in that file set the XPath will execute and will iterate the folder over and over again.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
gilles_charon
Posts: 3
Joined: Fri Feb 02, 2018 12:41 pm

Re: Exclude option from search in files

Post by gilles_charon »

yes, of course !!! Thanks.
Regards
Gilles
Post Reply