Matches a pattern against a filename.
Some characters of pattern have special a meaning (they are
) and can't be escaped. These are:
* |
Matches 0 or more instances of any character. |
? |
Matches exactly one instances of any character. |
[] |
Matches one instance of any character that appears
between the brackets. |
[!] |
Matches one instance of any character that does not appear
between the brackets after the exclamation mark. |
Internally individual character comparisons are done calling
charMatch(), so its rules apply here too. Note that path
separators and dots don't stop a meta-character from matching
further portions of the filename.
Returns:
true if pattern matches filename, false otherwise.
Throws:
Nothing.
version (Win32)
{
patternMatch("foo.bar", "*"); // => true
patternMatch(r"foo/foo\bar", "f*b*r"); // => true
patternMatch("foo.bar", "f?bar"); // => false
patternMatch("Goo.bar", "[fg]???bar"); // => true
patternMatch(r"d:\foo\bar", "d*foo?bar"); // => true
}
version (Posix)
{
patternMatch("Go*.bar", "[fg]???bar"); // => false
patternMatch("/foo*home/bar", "?foo*bar"); // => true
patternMatch("foobar", "foo?bar"); // => true
}