How can I search for files matching a regular expression?
I found \OCP\Files\Folder->search(string)
https://doc.owncloud.org/api/classes/OCP.Files.Folder.html#method_search
Unfortunately, the file search query is undocumented in the documentation, and I can’t find how to do a regular expression search.
I need to find files that match the following expression (case insensitive):
^.*ggr.*nr.*20[0-9][0-9].[0-9]{3}.*$
I tried with search string next
this works, it finds nextcloud-fles Nextcloud Manual.pdf
and Nextcloud.mp4
, but neither search string next*
nor next.*
find any files.
That’s my trial code, where $_['root']
is a OCP\Files\IRootFolder
:
foreach ($_['root']->getUserFolder('admin')->search('next') as $path) {
echo "→ ".$path->getName()."\n";
}