fnmatch +linux +x86_64

The fnmatch module provides an implementation of fnmatch string matching as defined by POSIX.




type flags;


fn fnmatch(str, str, flags...) bool;


type flags[link]

type flags = enum uint {
	NONE = 0,
	// If this flag is set, slashes in the string will only be matched by
// literal slashes in the pattern
PATHNAME = 1u << 0, // If this flag is set, backslash will be treated as an ordinary
// character
NOESCAPE = 1u << 1, // If this flag is set, a '.' at the beginning of the string can only
// be matched by a literal '.' in the pattern. If [[flags::PATHNAME]] is
// set simultaneously, this behavior also apply to any periods
// immediately following a slash.
PERIOD = 1u << 2, };

A set of flags that alter the matching behavior of fnmatch


fn fnmatch[link]

fn fnmatch(pattern: str, string: str, flag: flags...) bool;

Check whether the 'string' matches the 'pattern', which is a shell wildcard pattern with the following matching rules:

- '?' matches any single character - '*' matches any string, including the empty string - '[' and ']' enclose a bracket expression. Matching rules for bracket expressions are identical to those of bracket subexpressions in regular expressions, except that '!' takes the role of '^' when placed right after the opening '['. - '\' escapes the following character, e. g. "\*" only matches literal '*' and has no special meaning - all other characters only match themselves

A set of flags that alter the matching behavior may be passed to fnmatch. For an explanation of their meaning, see flags.