• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/tests/custom/03_stdlib/44_wildcard

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

This page was automatically generated by LXR 0.3.1.  •  OpenWrt