reference:evaluator:match

Match(
     string/array:string/array,
     string:pattern,
     [string:flags]
)
bool, int or string

Arguments

string/array

String or array to compare.

pattern

Pattern to compare against.

flags

Optional. Optional flags are:

cconsider case when performing the operation
xsimple matching against multiple file extensions
dsupport DOS wildcard characters only
ruse regular expression
heasy handling for file paths (\ and / are considered the same)
a"any word" mode
iignore diacritics
fsupport filetype groups
ppartial matching
nforce partial match on for regular expression (see below)

When matching an array the additional flags are:

greturn the string that matched rather than the index
yreturn an array of all matches rather than the first one

Return value

For strings, returns True if string matches the pattern. For arrays, returns either the matching index or string, or -1 for no match.

Description

For strings, returns True if the input string matches the specified wildcard pattern. For arrays, returns the first index that matched or -1 for no match.

By default this uses standard pattern matching - specify the r flag to use regular expressions instead.

For regular expression, partial match is automatically disabled if the pattern begins or ends with a .* sequence. To prevent this, specify the n flag. This forces partial match (as the "normal" regex behaviour), but you can perform a non-partial match by adding ^ to the start and $ to the end of the pattern.

Example:

if (Match(name, "*.txt")) { ... } // does file have a .txt extension?