({{, (RefLink[TextWords, paclet:ref/TextWords])["string"] 
gives a list of the runs of characters identified as words in string.}, {, (RefLink[TextWords, paclet:ref/TextWords])["string",n]
gives the first n words in string.}})

OpenersNotesSection(Spacer1)Details

Characters in string that are not identified as being part of words are dropped by (RefLink[TextWords, paclet:ref/TextWords]).

(RefLink[TextWords, paclet:ref/TextWords])[(RefLink[ContentObject, paclet:ref/ContentObject])[…]] gives words from the plain text contents of the (RefLink[ContentObject, paclet:ref/ContentObject]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (8)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Segment a string into a list of words:

TextWords["first second third fourth"]

TextWords["apple bear cat dog elephant"]

(RefLink[TextWords, paclet:ref/TextWords]) separates words by punctuation as well as whitespace:

TextWords["First sentence.  Second sentence.  Third sentence."]

TextWords["A phrase, and yet another phrase."]

Get the first 10 words in a block of text:

TextWords["In the fell clutch of circumstance
      I have not winced nor cried aloud.
Under the bludgeonings of chance
      My head is bloody, but unbowed.", 10]

TextWords[ResourceData["The Secret Sharer"],10]

OpenersExampleSection1(Spacer1)Scope  (1)

Get a list of words from a (RefLink[ContentObject, paclet:ref/ContentObject]):

file=Export[FileNameJoin[{$TemporaryDirectory,"hamlet.txt"}],ExampleData[{"Text","ToBeOrNotToBe"}]];
doc=ContentObject[File[file]]

TextWords[doc]

OpenersExampleSection3(Spacer1)Applications  (1)

Make a (RefLink[WordCloud, paclet:ref/WordCloud]) of words from a poem:

WordCloud[TextWords[ExampleData[{"Text","TheRaven"}]]]

OpenersExampleSection4(Spacer1)Properties & Relations  (2)

(RefLink[TextWords, paclet:ref/TextWords]) preserves hyphenation:

TextWords["The investment came from a London-based company."]

TextWords["He packed the meal in shrink-wrap."]

Titles, currencies, and other syntactic units are also preserved:

TextWords["50% of the school played a sport."]

TextWords["She spent $10 on lunch."]

TextWords["He spent 100€ on a trip to France."]

OpenersExampleSection5(Spacer1)Possible Issues  (1)

Words returned by (RefLink[TextWords, paclet:ref/TextWords]) are identified structurally, and may not be dictionary words:

TextWords["A li milk."]

DictionaryWordQ/@%

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[WordCount, paclet:ref/WordCount])  ▪  (RefLink[TextSentences, paclet:ref/TextSentences])  ▪  (RefLink[TextCases, paclet:ref/TextCases])  ▪  (RefLink[StringSplit, paclet:ref/StringSplit])  ▪  (RefLink[WordCounts, paclet:ref/WordCounts])  ▪  (RefLink[DeleteStopwords, paclet:ref/DeleteStopwords])  ▪  (RefLink[WordStem, paclet:ref/WordStem])  ▪  (RefLink[TextRecognize, paclet:ref/TextRecognize])  ▪  (RefLink[FeatureExtractor, paclet:ref/FeatureExtractor])  ▪  (RefLink[SequencePredict, paclet:ref/SequencePredict])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Text Manipulation, paclet:guide/ProcessingTextualData])}, {▪(RefLinkPlain[Text Normalization, paclet:guide/TextNormalization])}, {▪(RefLinkPlain[String Manipulation, paclet:guide/StringManipulation])}, {▪(RefLinkPlain[Text Analysis, paclet:guide/TextAnalysis])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/11-strings-and-text.html])(WebLink[: Strings and Text, https://www.wolfram.com/language/elementary-introduction/11-strings-and-text.html])}})}})