var re=null,i; for(i=0;i<10;i++){ re=/cat/g; if(re.test("catcapppp")){ alert("mmm"); }; }; for(i=0;i<10;i++){ re=new RegExp("cat","g"); if(re.test("catcapppp")){ alert("dddd"); }; }