Page 1 of 1
Exclude option from search in files
Posted: Fri Feb 02, 2018 12:51 pm
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
Re: Exclude option from search in files
Posted: Fri Feb 02, 2018 3:29 pm
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
Re: Exclude option from search in files
Posted: Tue Feb 06, 2018 4:07 pm
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
Re: Exclude option from search in files
Posted: Tue Feb 06, 2018 5:08 pm
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
Re: Exclude option from search in files
Posted: Tue Feb 13, 2018 7:18 pm
by gilles_charon
yes, of course !!! Thanks.
Regards
Gilles