In the example below the output is true. It cookie
and it also matches cookie14214
I'm guessing it's because cookie is in the string cookie14214
. How do I hone-in this match to only get cookie
?
var patt1=new RegExp(/(biscuit|cookie)/i);
document.write(patt1.test("cookie14214"));
Is this the best solution?
var patt1=new RegExp(/(^biscuit$|^cookie$)/i);