Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

The shExpMatch function in .pac files does not support regular expressions


View products that this article applies to.

Summary

When you use the shExpMatch function in .pac files, advanced regular expression syntax does not work in Internet Explorer.

↑ Back to the top


More information

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";
}
				

↑ Back to the top


References

For more information about the .pac file syntax, visit the following Netscape Web site: For more information on regular expressions, visit the following Mozilla Web site: Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.

↑ Back to the top


Properties

Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

↑ Back to the top


Keywords: KB274204, kbscript, kbinfo

↑ Back to the top

Article Info
Article ID : 274204
Revision : 4
Created on : 7/5/2007
Published on : 7/5/2007
Exists online : False
Views : 1125