Skip to main content

Glob Matching

FunctionDescriptionMeta
glob.match

result := glob.match(pattern, delimiters, match)

Parses and matches strings against the glob notation. Not to be confused with regex.globs_match.

Arguments:
pattern (string)

glob pattern

delimiters (any<null, array[string]>)

glob pattern delimiters, e.g. [".", ":"], defaults to ["."] if unset. If delimiters is null, glob match without delimiter.

match (string)

string to match against pattern

Returns:
result (boolean)

true if match can be found in pattern which is separated by delimiters

Wasm
glob.quote_meta

output := glob.quote_meta(pattern)

Returns a string which represents a version of the pattern where all asterisks have been escaped.

Arguments:
pattern (string)

glob pattern

Returns:
output (string)

the escaped string of pattern

SDK-dependent

The following table shows examples of how glob.match works:

calloutputDescription
output := glob.match("*.github.com", [], "api.github.com")trueA glob with the default ["."] delimiter.
output := glob.match("*.github.com", [], "api.cdn.github.com")falseA glob with the default ["."] delimiter.
output := glob.match("*hub.com", null, "api.cdn.github.com")trueA glob without delimiter.
output := glob.match("*:github:com", [":"], "api:github:com")trueA glob with delimiters [":"].
output := glob.match("api.**.com", [], "api.github.com")trueA super glob.
output := glob.match("api.**.com", [], "api.cdn.github.com")trueA super glob.
output := glob.match("?at", [], "cat")trueA glob with a single character wildcard.
output := glob.match("?at", [], "at")falseA glob with a single character wildcard.
output := glob.match("[abc]at", [], "bat")trueA glob with character-list matchers.
output := glob.match("[abc]at", [], "cat")trueA glob with character-list matchers.
output := glob.match("[abc]at", [], "lat")falseA glob with character-list matchers.
output := glob.match("[!abc]at", [], "cat")falseA glob with negated character-list matchers.
output := glob.match("[!abc]at", [], "lat")trueA glob with negated character-list matchers.
output := glob.match("[a-c]at", [], "cat")trueA glob with character-range matchers.
output := glob.match("[a-c]at", [], "lat")falseA glob with character-range matchers.
output := glob.match("[!a-c]at", [], "cat")falseA glob with negated character-range matchers.
output := glob.match("[!a-c]at", [], "lat")trueA glob with negated character-range matchers.
output := glob.match("{cat,bat,[fr]at}", [], "cat")trueA glob with pattern-alternatives matchers.
output := glob.match("{cat,bat,[fr]at}", [], "bat")trueA glob with pattern-alternatives matchers.
output := glob.match("{cat,bat,[fr]at}", [], "rat")trueA glob with pattern-alternatives matchers.
output := glob.match("{cat,bat,[fr]at}", [], "at")falseA glob with pattern-alternatives matchers.