From Dev.to
Word Counting Is Harder Than It Looks: A Dev's Guide
Every developer has written the naive version at least once: const words = text.trim().split(/\s+/).length; It works on a clean paragraph. Then a user pastes an essay and the number is wrong, and the...
