1、替换全部
String.prototype.replaceAll = function(s1, s2) { return this.replace(new RegExp(s1, "gm"), s2) }
2、清除空格
String.prototype.trim = function() { var reExtraSpace = /^/s*(.*?)/s+$/; return this.replace(reExtraSpace, "$1") }
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/8852.html