项目中用到字符串扩展


$.extend(String.prototype,
    {
        IsEmpty: function () {
            return /^s*$/.test(this);
        },
        Equals: function (str, ordinalIgnoreCase) {
            ordinalIgnoreCase = ordinalIgnoreCase || false;
            if (ordinalIgnoreCase) return $.trim(this.toLowerCase()) === $.trim(str.toLowerCase());
            return $.trim(this) === $.trim(str);
        },
        RealSn: function () {
            var sn = $.trim(this.toUpperCase());
            if (request("CC").Equals("Lenovo", true)) {   //CUSTOMER_CODE
                var tmp = sn.substr(0, 2);
                if (tmp.Equals("YL", true)) {
                    return sn.substr(0, 8);
                }

                tmp = sn.substr(sn.length - 8, 2);
                if (tmp.Equals("YL", true)) {
                    return sn.substr(sn.length - 8, 8);
                }
            }

            return sn;
        }
    });

原文地址:https://www.cnblogs.com/msvc/p/15262921.html