Last active
December 28, 2017 10:14
-
-
Save lushijie/5d6d1b09d1424243c95fedc12462b6e4 to your computer and use it in GitHub Desktop.
返回字符串的实际长度
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 返回字符串的实际长度, 一个汉字算2个长度 | |
String.prototype.strlen = function () { | |
return this.replace(/[^\x00-\xff]/g, "**").length; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment