JavaScript matches

To use the Javascript RegEx matches() function on a string, use the following code:

var myString = "foobar";
var pattern = /o+/;

if(myString.match(pattern)){
  alert("Found a match");
}