wildcard_match
| Definition: | integer i = wildcard_match(string st1, string st2) |
| Description: |
This function performs a general matching of a string against a pattern containing * and ? wildcards. true (1) if string st2 matches pattern st1. It returns false (0) otherwise. * matches any 0 or more characters. ? matches any single character. Character comparisons are case sensitive. |
| pwa/p2js: | Supported. |
| Comments: | For case insensitive comparisons, pass both st1 and st2 through upper(), or
lower() before calling this.
To detect a pattern anywhere within a string, add * to each end of the pattern:
i = wildcard_match('*' & pattern & '*', string)
There is currently no way to treat * or ? literally in a pattern. In Euphoria, this routine has been renamed as is_match, therefore an alias to that effect has been added to Phix. In effect the compiler quietly maps it back, and opening help for is_match in Edita opens this page. |
| Example 1: |
i = wildcard_match("A?B*", "AQBXXYY")
-- i is 1 (TRUE)
|
| Example 2: |
i = wildcard_match("*xyz*", "AAAbbbxyz")
-- i is 1 (TRUE)
|
| Example 3: |
i = wildcard_match("A*B*C", "a111b222c")
-- i is 0 (false) because upper/lower case does not match
|
| Implementation: | See builtins\wildcard.e (an autoinclude) for details of the actual implementation. |
| See Also: | regex.e, wildcard_file, match, upper, lower, compare |