Skip to content

Instantly share code, notes, and snippets.

@dgershman
Created November 8, 2012 20:59
Show Gist options
  • Save dgershman/4041563 to your computer and use it in GitHub Desktop.
Save dgershman/4041563 to your computer and use it in GitHub Desktop.
user agent detection with regexp
var str = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/12.0.782.220 Safari/535.1";
var found = (new RegExp("Chrome/1[2-3]", "g").exec(str));
alert(found);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment