I’m using the PHP class “Mobile Detect” to detect user device type (tablet/phone) however I also want to detect certain devices in javascript. Can someone help me convert the following into javascript regex (just need a true/false return)?
var user_agent = navigator.userAgent;
var samsung = 'Galaxy.*Tab|SAMSUNG.*Tablet|Galaxy.*Tab|Android.*GT-';
// if statement checking samsung regex against user agent
var nexus = '^.*Android.*Nexus(((?:(?!Mobile))|(?:(\s(7).+))).)*$';
// if statement checking nexus7 regex against user agent
Are you looking for something like this?
Or did you actually want help fixing malfunctioning / incomplete regular expressions?
If you need a solid regular expression, I suggest you go play around at txt2re.com it’s the best regular expression generator I know of.