var
str =
'abcadeacf'
;
var
str1 = str.replace(
'a'
,
'o'
);
alert(str1);
// 打印结果: obcadeacf
var
str2 = str.replace(/a/g,
'o'
);
alert(str2);
//打印结果: obcodeocf,
var
str =
'abcadeacf'
;
var
str1 = str.replace(
'a'
,
'o'
);
alert(str1);
// 打印结果: obcadeacf
var
str2 = str.replace(/a/g,
'o'
);
alert(str2);
//打印结果: obcodeocf,
转载于:https://www.cnblogs.com/dianzan/p/8031770.html