Go to: Synopsis. Return value. Related. MEL examples.
gmatch
string string
gmatch is NOT undoable, NOT queryable, and NOT editable.
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. "*" and "?" lose their special meanings between the brackets and simply match themselves. A pair of characters separated by "-" matches any character lexically between the pair, inclusive (e.g. "[0-9]" matches any digit). If the first character following the opening "[" is a "!" any character not enclosed is matched (e.g. "[!ab]" will match any character except "a" or "b"). A "-" can be included in the character set as itself by putting it as the first or last character. |
int | Matching value |
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 //