私信  •  关注

scripto

scripto 最近创建的主题
scripto 最近回复了
12 年前
回复了 scripto 创建的主题 » regex使用验证器传递变量值并验证jquery[duplicate]

下面是另一个replaceall实现:

    String.prototype.replaceAll = function (stringToFind, stringToReplace) {
        if ( stringToFind == stringToReplace) return this;
        var temp = this;
        var index = temp.indexOf(stringToFind);
        while (index != -1) {
            temp = temp.replace(stringToFind, stringToReplace);
            index = temp.indexOf(stringToFind);
        }
        return temp;
    };