INFO: The shExpMatch Function in .pac Files Does Not Support Regular Expressions (274204)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 4.0
  • Microsoft Internet Explorer (Programming) 4.01
  • Microsoft Internet Explorer (Programming) 4.01 SP1
  • Microsoft Internet Explorer (Programming) 4.01 SP2
  • Microsoft Internet Explorer (Programming) 5
  • Microsoft Internet Explorer (Programming) 5.01
  • Microsoft Internet Explorer (Programming) 5.01 SP1
  • Microsoft Internet Explorer (Programming) 5.5

This article was previously published under Q274204

SUMMARY

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

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

REFERENCES

For more information about the .pac file syntax, refer to the following Netscape Web site: For more information on regular expressions, refer to the following Netscape 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.

Modification Type:MajorLast Reviewed:5/10/2003
Keywords:kbinfo kbScript KB274204