Reputation: 899
Parsing the user-agent header I need to find out if I am dealing with IE-8 or earlier:
<= IE8
So the regex should return true in the following cases:
(compatible; MSIE 8.0;...)
(compatible; MSIE 7.0;...)
etc.
The following should yield false:
(compatible; MSIE 9.0;...)
This following regex does not work:
"MSIE [6-8]\."
Upvotes: 1
Views: 3170
Reputation: 375
Your pattern should work if you escape the backslash, or did you mean JavaScript?. (in which case it should work)
"(?i)MSIE\\s+[5-8]\\.\\d+"
Explanation:
(?i)
makes the match case insensitiveMSIE
matches the string MSIE\\s+
one or more spaces[5-8]
matches digits 5 to 8\\.
match a dot\\d+
one or more digitsUpvotes: 4
Reputation: 2545
You can use character groups to match versions, f.i. [678]\.0
.
Upvotes: 0