Microsoft KB Archive/274204

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

Article ID: 274204

Article Last Modified on 7/5/2007

-

APPLIES TO


 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 4.01 Service Pack 1
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer (Programming) 5.01 SP1
 * Microsoft Internet Explorer 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 &quot;?&quot; and &quot;*&quot; 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 &quot;MSDN&quot;, route it through a specific proxy:

var regexpr = /[a-zA-Z]{4}.microsoft.com/; if(regexpr.test(host)) return &quot;PROXY w3proxy:8080; DIRECT&quot;;

// Or else connect directly: return &quot;DIRECT&quot;; }

