String.prototype.lenB = function(){return this.replace(/[^/x00-/xff]/g,"**").length;} var str="我是一年兵asdfasdf"; alert(str.lenB());