String module

wildcard_match

procedure · 1 overloadSource

Whether the whole of s matches the pattern pat.

wildcard_match :: (s: string, pat: string) -> bool

In the pattern * matches any run of bytes (also none), ? matches any one byte, and [a-c] matches one byte in a set of bytes and ranges ([abc], [0-9]). There is no negation or escape; put * in brackets to match it literally. A [ with no closing ] matches nothing. Matching works on bytes, not characters.

Parameters

s: string
pat: string

Returns

bool
ExampleOpen in playground ↗
assert(wildcard_match("main.jai", "*.jai"));
assert(wildcard_match("v2", "v[0-9]"));
assert(!wildcard_match("ab", "a?b"));