String.prototype.sub = function (n) var r = /[^\x00-\xff]/g; if (this.replace(r, "mm").length <= n) return this; // n = n - 3; var m = Math.floor(n / 2); for (var i = m; i < this.length; i++) if (this.substr(0, i).replace(r, "mm").length >= n) return this.substr(0, i); }我。。知。。道加。。我。。私。。聊