true if pattern matches filename, false otherwise.
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 }
version (Win32) assert(patternMatch("foo", "Foo")); version (Posix) assert(!patternMatch("foo", "Foo")); assert(patternMatch("foo", "*")); assert(patternMatch("foo.bar", "*")); assert(patternMatch("foo.bar", "*.*")); assert(patternMatch("foo.bar", "foo*")); assert(patternMatch("foo.bar", "f*bar")); assert(patternMatch("foo.bar", "f*b*r")); assert(patternMatch("foo.bar", "f???bar")); assert(patternMatch("foo.bar", "[fg]???bar")); assert(patternMatch("foo.bar", "[!gh]*bar")); assert(!patternMatch("foo", "bar")); assert(!patternMatch("foo", "*.*")); assert(!patternMatch("foo.bar", "f*baz")); assert(!patternMatch("foo.bar", "f*b*x")); assert(!patternMatch("foo.bar", "[gh]???bar")); assert(!patternMatch("foo.bar", "[!fg]*bar")); assert(!patternMatch("foo.bar", "[fg]???baz"));
Matches a pattern against a filename.
Some characters of pattern have special a meaning (they are meta-characters) and can't be escaped. These are:
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.