Go to: Return value. Related commands. Examples.

Synopsis

gmatch <string> <string>

Returns a non-zero result if the pattern specified by the second argument matches the search string in the first argument.

gmatch provides shell-style pattern matching, also known as "glob" matching. There are three ways to specify wild cards in this type of matching and they are as follows:

* matches any string
? matches any single character
[...] Matches any one of the enclosed characters. A pair of characters separated by - matches any character lexically between the pair, inclusive. If the first character following the opening "[ " is a "!" any character not enclosed is matched. A - can be included in the character set by putting it as the first or last character.

Return value

int

Related commands

match, strcmp

Examples


	gmatch "matches" "m*s";
	// Result: 1 //
	gmatch "matches" "mat*";
	// Result: 1 //
	gmatch "matches" "ma[a-z]ches";
	// Result: 1 //
	gmatch "matches" "ma[!a-m]ches";
	// Result: 1 //
	gmatch "matches" "ma?ches";
	// Result: 1 //
	gmatch "no match" "?atch";
	// Result: 0 //