CCalclabhub

Text & Writing

Counting words by whitespace

Trim the text, then split it on runs of whitespace. Each resulting piece is one word, regardless of the punctuation it carries.

The Formula

words = number of whitespace-separated tokens

Trim the text, then split it on runs of whitespace. Each resulting piece is one word, regardless of the punctuation it carries.

SymbolMeaning
tToken
WWord count

What Each Symbol Means

ttoken

Token

A maximal run of characters with no whitespace inside.

Wwords

Word count

How many such tokens the text contains.

See It Worked With Real Numbers

A formula on its own does not tell you which number goes where. The how to count words page applies this equation to a concrete case, shows every intermediate step, and names the mistakes that produce a wrong answer even when the algebra is right.

Where This Formula Appears

This equation is the working core of How To Count Words, filed under Everyday Life. Every number the guide produces comes from substituting into this one line.