Last active
June 30, 2017 00:50
-
-
Save jiyu3/b16ee866e8191a7cafce82588f3617d2 to your computer and use it in GitHub Desktop.
単語数をカウントする(英語) ref: http://qiita.com/jiyu/items/05126d4e8888ff7d4909
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
function countWords(text) { | |
return (text+=".").replace(/(\,|\.|:|;|\!|\?|\s)+/g, " ").split(" ").length - 1; | |
} | |
countWords(`I am Jiyu; Jiyu means "Freedom" or "Liberty" in Japanese.`); // 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment