扩展JavaScript的String对象方法:
?
1. replaceAll方法
String.prototype.replaceAll = function(regStr, replaceStr) { var reg = new RegExp(regStr, "gm"); return this.replace(reg, replaceStr); }
?
?
2. trim方法
String.prototype.trim = function() { var reg = /^\s+(.*?)\s+$/; return this.replace(reg, "$1"); }
?