WOLFRAM

TextWords["string"]

gives a list of the runs of characters identified as words in string.

TextWords["string",n]

gives the first n words in string.

Details

Examples

open allclose all

Basic Examples  (3)Summary of the most common use cases

Segment a string into a list of words:

Out[1]=1
Out[2]=2

TextWords separates words by punctuation as well as whitespace:

Out[1]=1
Out[2]=2

Get the first 10 words in a block of text:

Out[1]=1
Out[2]=2

Scope  (3)Survey of the scope of standard use cases

TextWords preserves hyphenation:

Out[1]=1
Out[2]=2

Titles, currencies and other syntactic units are segmented as separate words:

Out[1]=1
Out[2]=2
Out[3]=3

Get a list of words from a ContentObject:

Out[1]=1
Out[2]=2

Applications  (1)Sample problems that can be solved with this function

Make a WordCloud of words from a poem:

Out[1]=1

Properties & Relations  (2)Properties of the function, and connections to other functions

TextWords is equivalent to TextCases[,"Word"]:

Out[1]=1
Out[2]=2

TextStructure splits texts into the same words:

Out[1]=1
Out[2]=2

Possible Issues  (1)Common pitfalls and unexpected behavior

Words returned by TextWords are identified structurally, and may not be dictionary words:

Out[1]=1
Out[2]=2
Wolfram Research (2015), TextWords, Wolfram Language function, https://reference.wolfram.com/language/ref/TextWords.html (updated 2016).
Wolfram Research (2015), TextWords, Wolfram Language function, https://reference.wolfram.com/language/ref/TextWords.html (updated 2016).

Text

Wolfram Research (2015), TextWords, Wolfram Language function, https://reference.wolfram.com/language/ref/TextWords.html (updated 2016).

Wolfram Research (2015), TextWords, Wolfram Language function, https://reference.wolfram.com/language/ref/TextWords.html (updated 2016).

CMS

Wolfram Language. 2015. "TextWords." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/TextWords.html.

Wolfram Language. 2015. "TextWords." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/TextWords.html.

APA

Wolfram Language. (2015). TextWords. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TextWords.html

Wolfram Language. (2015). TextWords. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TextWords.html

BibTeX

@misc{reference.wolfram_2025_textwords, author="Wolfram Research", title="{TextWords}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/TextWords.html}", note=[Accessed: 08-July-2025 ]}

@misc{reference.wolfram_2025_textwords, author="Wolfram Research", title="{TextWords}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/TextWords.html}", note=[Accessed: 08-July-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_textwords, organization={Wolfram Research}, title={TextWords}, year={2016}, url={https://reference.wolfram.com/language/ref/TextWords.html}, note=[Accessed: 08-July-2025 ]}

@online{reference.wolfram_2025_textwords, organization={Wolfram Research}, title={TextWords}, year={2016}, url={https://reference.wolfram.com/language/ref/TextWords.html}, note=[Accessed: 08-July-2025 ]}