LoginSignup
5
5

More than 5 years have passed since last update.

単語数をカウントする(英語)

Last updated at Posted at 2017-06-12
function countWords(text) {
    return (text+=".").replace(/(\,|\.|:|;|\!|\?|\s)+/g, " ").split(" ").length - 1;
}

countWords(`I am Jiyu; Jiyu means "Freedom" or "Liberty" in Japanese.`); // 10
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5