Skip to content

Instantly share code, notes, and snippets.

@jiyu3
Last active June 30, 2017 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jiyu3/b16ee866e8191a7cafce82588f3617d2 to your computer and use it in GitHub Desktop.
Save jiyu3/b16ee866e8191a7cafce82588f3617d2 to your computer and use it in GitHub Desktop.
単語数をカウントする(英語) ref: http://qiita.com/jiyu/items/05126d4e8888ff7d4909
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