WordCount["string"]
gives the total number of words in string.
WordCount
WordCount["string"]
gives the total number of words in string.
Details
- Character sequences in "string" that are not identified as being part of words are excluded from WordCount.
Examples
open all close allBasic Examples (1)
Properties & Relations (2)
Neat Examples (1)
Find the sentence with the most words in a book:
alice = StringReplace[ExampleData[{"Text", "AliceInWonderland"}], ";" -> "."];sentences = TextSentences[alice];MaximalBy[sentences, WordCount, 1]Compare to the longest sentence by string length:
MaximalBy[sentences, StringLength, 1]Related Guides
History
Text
Wolfram Research (2015), WordCount, Wolfram Language function, https://reference.wolfram.com/language/ref/WordCount.html.
CMS
Wolfram Language. 2015. "WordCount." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/WordCount.html.
APA
Wolfram Language. (2015). WordCount. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/WordCount.html
BibTeX
@misc{reference.wolfram_2026_wordcount, author="Wolfram Research", title="{WordCount}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/WordCount.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_wordcount, organization={Wolfram Research}, title={WordCount}, year={2015}, url={https://reference.wolfram.com/language/ref/WordCount.html}, note=[Accessed: 12-June-2026]}