Detecting iOS Version Number from User Agent using Regular Expressions
If I have an iOS user-agent like Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7 or Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Mobile/7D11 How would I detect the iOS version using regular expressions so that it would return e.g. 4.0 for the above user agent? The RegEx that is working for me is: /OS ((\d+_?){2,3})\s/ An iPad 5.1.1 has an HTTP_USER_AGENT like this: "Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML,