Word Counter

Counting the number of words in the text.




Number of Words - 0

How This Converter Works

Counts the pieces produced by splitting on one or more whitespace characters followed by a word boundary; this is not a conventional word-token count.

Formula or rule

Count = input.split(/\s+\b/).length. An empty string therefore produces a count of 1.

Example

Input
red blue
Calculation
The space before the word boundary splits the string into red and blue.
Result
2