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. It returns 1 (true) if string st2 matches pattern st1. It returns 0 (false) otherwise. * matches any 0 or more characters. ? matches any single character. Character comparisons are case sensitive. |
Comments: | If you want case insensitive comparisons, pass both st1 and st2
through upper(), or both through lower() before calling
wildcard_match().
If you want 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 OpenEuphoria, 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 |
Example Program: | bin\search.ex |
See Also: | wildcard_file, match, upper, lower, compare |