Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Perform a regular expression match
<?php preg_match(    string $pattern,    string $subject,    array &$matches = null,    int $flags = 0,    int $offset = 0): int|false
<?php             return false;

        }



        if (!preg_match(self::toRegEx($glob, $flags), $path)) {

            return false;

        }
<?php         $staticPrefix = self::getStaticPrefix($glob, $flags);

        $regExp = self::toRegEx($glob, $flags);

        $filter = function ($path) use ($staticPrefix, $regExp) {

            return 0 === strpos($path, $staticPrefix) && preg_match($regExp, $path);

        };



        if (PHP_VERSION_ID >= 50600) {
<?php             return false;

        }



        $result = (bool) preg_match($this->regExp, $path);



        return $result;

    }
<?php     {

        $regExp = Glob::toRegEx('/foo/*.js~');



        $this->assertSame($isMatch, preg_match($regExp, $path));

    }
<?php     {

        $regExp = Glob::toRegEx('/foo/**/*.js~');



        $this->assertSame($isMatch, preg_match($regExp, $path));

    }



    public function provideWildcardMatches()
<?php         $regExp = Glob::toRegEx('/foo/\\*.js~');



        $this->assertSame(0, preg_match($regExp, '/foo/baz.js~'));

        $this->assertSame(1, preg_match($regExp, '/foo/*.js~'));

        $this->assertSame(0, preg_match($regExp, '/foo/\\baz.js~'));

        $this->assertSame(0, preg_match($regExp, '/foo/\\*.js~'));
<?php         $regExp = Glob::toRegEx('/foo/\\*.js~');



        $this->assertSame(0, preg_match($regExp, '/foo/baz.js~'));

        $this->assertSame(1, preg_match($regExp, '/foo/*.js~'));

        $this->assertSame(0, preg_match($regExp, '/foo/\\baz.js~'));

        $this->assertSame(0, preg_match($regExp, '/foo/\\*.js~'));

    }
<?php         $this->assertSame(0, preg_match($regExp, '/foo/baz.js~'));

        $this->assertSame(1, preg_match($regExp, '/foo/*.js~'));

        $this->assertSame(0, preg_match($regExp, '/foo/\\baz.js~'));

        $this->assertSame(0, preg_match($regExp, '/foo/\\*.js~'));

    }
<?php         $this->assertSame(0, preg_match($regExp, '/foo/baz.js~'));

        $this->assertSame(1, preg_match($regExp, '/foo/*.js~'));

        $this->assertSame(0, preg_match($regExp, '/foo/\\baz.js~'));

        $this->assertSame(0, preg_match($regExp, '/foo/\\*.js~'));

    }



    public function testEscapedWildcard2()
<?php         $regExp = Glob::toRegEx('/foo/\*.js~');



        $this->assertSame(0, preg_match($regExp, '/foo/baz.js~'));

        $this->assertSame(1, preg_match($regExp, '/foo/*.js~'));

        $this->assertSame(0, preg_match($regExp, '/foo/\\baz.js~'));

        $this->assertSame(0, preg_match($regExp, '/foo/\\*.js~'));
<?php         $regExp = Glob::toRegEx('/foo/\*.js~');



        $this->assertSame(0, preg_match($regExp, '/foo/baz.js~'));

        $this->assertSame(1, preg_match($regExp, '/foo/*.js~'));

        $this->assertSame(0, preg_match($regExp, '/foo/\\baz.js~'));

        $this->assertSame(0, preg_match($regExp, '/foo/\\*.js~'));

    }
<?php         $this->assertSame(0, preg_match($regExp, '/foo/baz.js~'));

        $this->assertSame(1, preg_match($regExp, '/foo/*.js~'));

        $this->assertSame(0, preg_match($regExp, '/foo/\\baz.js~'));

        $this->assertSame(0, preg_match($regExp, '/foo/\\*.js~'));

    }
<?php         $this->assertSame(0, preg_match($regExp, '/foo/baz.js~'));

        $this->assertSame(1, preg_match($regExp, '/foo/*.js~'));

        $this->assertSame(0, preg_match($regExp, '/foo/\\baz.js~'));

        $this->assertSame(0, preg_match($regExp, '/foo/\\*.js~'));

    }



    public function testMatchEscapedWildcard()
<?php         $regExp = Glob::toRegEx('/foo/\\*.js~');



        $this->assertSame(1, preg_match($regExp, '/foo/*.js~'));

    }



    public function testMatchEscapedDoubleWildcard()
<?php         $regExp = Glob::toRegEx('/foo/\\*\\*.js~');



        $this->assertSame(1, preg_match($regExp, '/foo/**.js~'));

    }



    public function testMatchWildcardWithLeadingBackslash()