I'm searching this string for an the 'invite=XXXX' part. I am using a capturing group to extract the value between '=' and ';'. When I use the first regex method it works, but when I use the second it doesn't. Why is this?
var string = "path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT; invite=1323969929057; path=/; expires=Sat, 14 Jan 2012 17:25:29 GMT;";
// first method
var regex1 = /invite=(\w+)/;
var regexMatch1 = string.match(regex1);
// second method
var regex2 = new RegExp("/invite=(\w+)/");
var regexMatch2 = string.match(regex2);
// log results
console.log(regexMatch1);
console.log(regexMatch2);