I’ve added function wildcard_compare($wildcard, $string) into YF framework, which uses php built-in fnmatch() function, which is fast and not using regexps.
There is support for these patterns:
“*” – no or any number of symbols
“?” – exactly one symbol
“[abc]” – one of symbols passed inside square brackets
YF function wildcard_compare() differs from native fnmatch(): it can accept array of wildcards and if any of them matched – then overall return true.
Examples:
wildcard_compare('regex are * useful', 'regex are always useful')
Function source:
https://github.com/yfix/yf/blob/master/share/functions/yf_common_funcs.php#L397
Unit tests (also examples):
https://github.com/yfix/yf/blob/master/.dev/tests/unit/functions/function_wildcard_compare.Test.php