Having problems with RegExp in javascript. I'm trying to return just the version number and browser name ie "firefox 22.0" or "msie 8.0"
console.log(navigatorSaysWhat())
function navigatorSaysWhat()
{
var rexp = new RegExp(/(firefox|msie|chrome|safari)\s(\d+)(\.)(\d+)/i);
// works in ie but not in firefox
var userA = navigator.userAgent
var nav = userA.match(rexp);
return nav
}
The above expression doesn't quite work. I' m trying to match browser name and version number from the strings.
Mozilla/5.0 (Windows NT 5.1; rv:22.0) Gecko/20100101 Firefox/22.0 Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0;
I've tried (firefox|msie|chrome|safari)\s(\d+)(./\/)(\d+) to match the backslash or (firefox|msie|chrome|safari)\s(\d+)(*)(\d+) for any character, but no dice.