I have compiled this regex that should only return a match, where the user agent string is IE 5, 6, 7, and 8. Obviously, one of the main goals here is to avoid the confusing IE11 user agent string ..
Is this Regex valid (I missed something)?
.*MSIE [5-8]\b((?!Trident/4.0)).*
UPDATE
Below are all user agent strings for 5, 6, 7, and 8. And none of 9, 10. However, it matches one for IE11 returned from .Net using Request.UserAgent
'Mozilla / 4.0 (compatible; MSIE 7.0; Windows NT 6.3; WOW64; Trident / 7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729 ) '
^.*MSIE [5-8](?:\.[0-9]+)?(?!.*Trident\/6\.0\)).*$
source
share