1、repleace 使用函数
var strM = "javascript is a good script language";
function change(word,t)
{
alert(t);
//return word.indexOf(0).toUpperCase()+word.substring(1);
}
alert(strM.replace(/\b\w+(t)\b/g,function(m,c,t){if(m=="script")return "hello"; else return "s";}));//m指正则匹配到的string,c指正则括号里面的匹配,t指匹配到的单词的位置