Glob

class Glob

Glob matches globbing patterns against text.

if match_glob("foo.*", "foo.bar") echo "matched\n";

// prints foo.bar and foo.baz $regex = globtoregex("foo.*"); for (array('foo.bar', 'foo.baz', 'foo', 'bar') as $t) { if (/$regex/) echo "matched: $car\n"; }

Glob implements glob(3) style matching that can be used to match against text, rather than fetching names from a filesystem.

Based on the Perl Text::Glob module.

Methods

static string toRegex(string $glob, bool $strictLeadingDot = true, bool $strictWildcardSlash = true, string $delimiter = '#')

Returns a regexp which is the equivalent of the glob pattern.

Details

static string toRegex(string $glob, bool $strictLeadingDot = true, bool $strictWildcardSlash = true, string $delimiter = '#')

Returns a regexp which is the equivalent of the glob pattern.

Parameters

string $glob The glob pattern
bool $strictLeadingDot
bool $strictWildcardSlash
string $delimiter Optional delimiter

Return Value

string regex The regexp

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/4.0/Symfony/Component/Finder/Glob.html