自定义扩展js函数库---string.replaceAll()---字符替换所有指定字符

/*
 * 自定义扩展js函数库 
 * @time:181203
 * @add : string.replaceAll()---字符替换所有指定字符
 */


/*
 * string.replaceAll()---字符替换所有指定字符
 * @parameter: FindText--原文本要替换值
 * @parameter: RepText--将要替换值
 */
String.prototype.replaceAll = function (FindText, RepText) {
    var regExp = new RegExp(FindText, "g");
    return this.replace(regExp, RepText);
}

猜你喜欢

转载自blog.csdn.net/stone10086/article/details/84761615