The
shExpMatch function is used in .pac files to match the current URL against any shell expression. In addition,
shExpMatch is usually used to decide which proxy to use depending on the URL that is entered. In Internet Explorer, the support for shell expressions is limited to "?" and "*" in the expressions. This is by design.
Because .pac files support the entire JavaScript language, you can use a regular expression object and the test method to test a string against a regular expression. The following code sample illustrates the use of the regular expression object in a .pac file:
function FindProxyForURL(url, host)
{
// For instance, if the server has 4 alphabetic characters,
// such as "MSDN", route it through a specific proxy:
var regexpr = /[a-zA-Z]{4}.microsoft.com/;
if(regexpr.test(host))
return "PROXY w3proxy:8080; DIRECT";
// Or else connect directly:
return "DIRECT";
}