Word Counter
How This Converter Works
Counts the pieces returned by JavaScript's split rule /\s+\b/. This can differ from a normal word count, and empty input returns 1.
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