<script>
//JS实现VBS当中的Replace,替换全部.方法名大写,区别于原方法,与VBS相类似.
String.prototype.Replace = function(oldValue,newValue,isIgnore)
{
var reg = new RegExp(oldValue,(isIgnore ? 'i' : '') + "g");
return this.replace(reg, newValue);
}
</script>
调用方式:
<script>
var str1 = 'ABCABcAbcaBCaBcabCabc'.Replace('abc','ABC'); // ABCABcAbcaBCaBcabCABC
var str2 = 'ABCABcAbcaBCaBcabCabc'.Replace('abc','ABC',true); // ABCABCABCABCABCABCABC
</script>