过滤名称中以句点开头的文件(正则表达式,elfinder+codeigner)



我在这里搜索了一些关于我的问题的主题,但我没有找到,或者有些不适合我。

我在codeigniter中使用elfinder,然后在连接器文件中,我需要过滤以句点字符开头的文件名。我想这样做是因为文件管理器显示.tmb(缩略图)文件夹,我不想。。。我只想过滤所有以句点开头的文件名:

.tmb.htaccess文件夹文件.任何文件或文件夹

我试过很多正则表达式('pattern'=>'/^TEST$/'),但对我不起作用。

谢谢!

    public function elfinder_init(){
    if ($this->session->userdata('name')) {
        $ruta = trim($this->input->get("path"));
        $opts = array(
             //'debug' => true,
                'roots' => array(
                            array(
                                'driver' => 'LocalFileSystem',
                                'path'   => set_realpath($ruta),
                                'URL'    => site_url($ruta) . "/",
                                'accessControl' => 'access',
                                'defaults' => array('read' => true, 'write' => true),
                                'encoding' => '',
                                'attributes' => array(
                                        array(
                                                'pattern' => '/^TEST$/',
                                                'hidden' => true,
                                                'read'    => true,
                                                'write'   => true,
                                                'locked'  => false
                                        )
                                )
                                // more elFinder options here
                            )
                )
        );

        $this->load->library('elfinder_lib', $opts);
    }
}

我找到了一种使用下一种模式隐藏缩略图文件夹的方法:

'pattern' => '/.tmb$/',

尽管我认为最好的方法是对所有以句点开头的文件名使用其他模式,而不仅仅是.tmb文件夹。。。

我还尝试在php文件中使用下一个代码:

if (preg_match("/^./", ".tmb")) 
    echo "The name has a dot";
else
    echo "The name hasn't dot";

它运行良好。。。为什么不按模式工作?我不明白。。。xd

最新更新