Browser version detection (opera and chrome complication)

戏子无情 提交于 2019-12-13 06:27:19

问题


I'm trying to detect version using regex of following browsers : Firefox, IE, Opera, Chrome and Safari.

Testing following userAgent information. If push |Chrome in regex than the result I am getting is 31.0.1650.63 instead of 18.0.1284.68

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 OPR/18.0.1284.68 (Opera Browser)

Here is regex :

/(?:Firefox|MSIE|Version|OPR).?([0-9.]+)/i

This regex working just fine with all browsers which is included , but if I push |Chrome in marked expression then chrome and opera versions become complicated . Any advice how I can solve this problem with one regex statement , thanks ...

NOTE : Without any library . Question isn't repeated , existence examples uses libraries or kind of different situations

来源:https://stackoverflow.com/questions/20843770/browser-version-detection-opera-and-chrome-complication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!