filenameMatch

fnbool filenameMatch(string name, string pattern) @trusted

Matches a filename against a pattern.

The pattern can contain the following wildcards:

  • `*` matches any sequence of characters
  • `?` matches any single character
  • [set] matches any character in the set
  • [^set] matches any character not in the set

Parameters

nameFilename to test
patternPattern to match against

Returns

true if the filename matches the pattern.

Example:

assert(filenameMatch("file.txt", "*.txt"));
assert(filenameMatch("file.txt", "file.*"));
assert(!filenameMatch("file.txt", "*.doc"));