Glob Matching
Function | Description | Meta |
---|---|---|
glob.match |
Parses and matches strings against the glob notation. Not to be confused with Arguments: Returns:pattern (string)glob pattern delimiters (any<null, array[string]>)glob pattern delimiters, e.g. match (string)string to match against result (boolean)true if | Wasm |
glob.quote_meta |
Returns a string which represents a version of the pattern where all asterisks have been escaped. Arguments: Returns:pattern (string)glob pattern output (string)the escaped string of | SDK-dependent |
The following table shows examples of how glob.match
works:
call | output | Description |
---|---|---|
output := glob.match("*.github.com", [], "api.github.com") | true | A glob with the default ["."] delimiter. |
output := glob.match("*.github.com", [], "api.cdn.github.com") | false | A glob with the default ["."] delimiter. |
output := glob.match("*hub.com", null, "api.cdn.github.com") | true | A glob without delimiter. |
output := glob.match("*:github:com", [":"], "api:github:com") | true | A glob with delimiters [":"] . |
output := glob.match("api.**.com", [], "api.github.com") | true | A super glob. |
output := glob.match("api.**.com", [], "api.cdn.github.com") | true | A super glob. |
output := glob.match("?at", [], "cat") | true | A glob with a single character wildcard. |
output := glob.match("?at", [], "at") | false | A glob with a single character wildcard. |
output := glob.match("[abc]at", [], "bat") | true | A glob with character-list matchers. |
output := glob.match("[abc]at", [], "cat") | true | A glob with character-list matchers. |
output := glob.match("[abc]at", [], "lat") | false | A glob with character-list matchers. |
output := glob.match("[!abc]at", [], "cat") | false | A glob with negated character-list matchers. |
output := glob.match("[!abc]at", [], "lat") | true | A glob with negated character-list matchers. |
output := glob.match("[a-c]at", [], "cat") | true | A glob with character-range matchers. |
output := glob.match("[a-c]at", [], "lat") | false | A glob with character-range matchers. |
output := glob.match("[!a-c]at", [], "cat") | false | A glob with negated character-range matchers. |
output := glob.match("[!a-c]at", [], "lat") | true | A glob with negated character-range matchers. |
output := glob.match("{cat,bat,[fr]at}", [], "cat") | true | A glob with pattern-alternatives matchers. |
output := glob.match("{cat,bat,[fr]at}", [], "bat") | true | A glob with pattern-alternatives matchers. |
output := glob.match("{cat,bat,[fr]at}", [], "rat") | true | A glob with pattern-alternatives matchers. |
output := glob.match("{cat,bat,[fr]at}", [], "at") | false | A glob with pattern-alternatives matchers. |