Last active
October 14, 2015 11:20
-
-
Save RhinoLu/9630d28f240a847b6aba to your computer and use it in GitHub Desktop.
判斷字串中有幾個中文字 check how many chinese words in a string
This file contains hidden or 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
var str = "test 測試"; | |
var chineseCount = str.split(/[\u4e00-\u9fa5]/).length - 1; | |
console.log(chineseCount); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment