<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>
新闻热点
疑难解答