js中替換字符串
//要求把一個字符串里把所有的“a”和“A”替換成“B”;
function fun()
{
var str ="abcAd";
var str2 ="a";
str = str.toLowerCase();
alert(str);
str=str.replace(new RegExp(str2,"g"),"B");
alert(str);
}
posted on 2010-06-25 17:29 何方 閱讀(200) 評論(0) 編輯 收藏 所屬分類: Stack