1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
The `wildcard()` function tests whether the given wildcard pattern matches
the given subject, optionally ignoring letter case.
Returns `true` if the pattern matches the subject.
Returns `false` if the pattern does not match the subject.
Returns `null` if the pattern argument is not a string value.
-- Testcase --
{%
printf("%.J\n", [
// A simple glob pattern match
wildcard("file.txt", "*.txt"),
// Using `?` as single character placeholder and case folding
wildcard("2022-02-02_BACKUP.LIST", "????-??-??_backup.*", true),
// Using bracket expressions
wildcard("aaa_123_zzz", "[a-z][a-z][a-z]_???_*"),
// Using no meta characters at all
wildcard("test", "test"),
// No match yields `false`
wildcard("abc", "d*"),
// Invalid pattern value yields `null`
wildcard("true", true)
]);
%}
-- End --
-- Expect stdout --
[
true,
true,
true,
true,
false,
null
]
-- End --
|