Best regex pattern to match non SP1 IE6 in user agent string?
I need some code to match all non-SP1 IE6 versions (part of Windows XP SP2 confused by eh). This means that gzip is disabled for versions of IE that do not handle it properly.
The best I have come up with this:
MSIE [1-6]\.(?!.*?SV1)
Who has the best model? What the above regex does is basically pretend to make sure SV1 (which SP1 points out) doesn't exist.
For testing purposes, this shouldn't be the same:
Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4325)
But this should:
Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 6.0)
+1
a source to share
2 answers
Your regex does a great job of matching the user agent you're looking for, but you should be aware that some browsers have "MSIE 6.0" in their user agent string for compatibility reasons. Here's a list of user agent strings .
0
a source to share