function replace(){ var str="tao zhang yi love liu weng ling"; re=new RegExp("l","g"); var newstart=str.replace(re,"t"); alert(newstr);}