var test = '9test and another 8Test, then tset and 7test again. teSt or tesT Test.'; var parser = XRegExp("(?<tname> Test)"); var parts = parser.exec(test); console.log(parts.tname);
There's also a good bit more functionality with this plugin, so I won't waist your time here. Head on over and check it out.