shExpMatch()
Shell-glob match of str against pattern; * matches any sequence, ? one character. The whole string must match.
shExpMatch(str, pattern) → booleanThe helper libraries convert the glob into a regular expression. * also matches dots, so
shExpMatch(host, "*example.com") matches notexample.com; use "*.example.com". Matching on
url instead of host lets a query string such as ?r=example.com trigger the rule.
Example
if (shExpMatch(host, "*.example.com") || host == "example.com") {
return "DIRECT";
}
Engine notes
| Engine | Behaviour | Source |
|---|---|---|
| chromium | Converts the glob to a RegExp escaping only '.', so ( ) | keep their regex meaning. | code, verified 2026-10-04 |
| firefox | Same conversion as Chromium (escapes '.', maps * and ?). | code, verified 2026-10-04 |
Availability
| Function | chromium | chromium | firefox | pacparser | pacparser | pacparser | reference |
|---|---|---|---|---|---|---|---|
shExpMatch | yes | yes | yes | yes | yes | yes | yes |