User:Muchos/Snippets/Wordcounter

Approximating word count in a string by counting spaces (by User:HumansCanWinElves, 2023-08-25).

Code depends on the way the String module is installed.

Basic form
Result:

Advanced method
(Ignores multiple spaces, takes linebreaks in account.)

Result: