Re: Number of Words in a String

*To*: mathgroup at smc.vnet.net*Subject*: [mg102529] Re: Number of Words in a String*From*: Yves Klett <yves.klett at googlemail.com>*Date*: Wed, 12 Aug 2009 04:36:04 -0400 (EDT)*References*: <h5r8b5$l4q$1@smc.vnet.net>

Hi, directly from the documentation: StringCount["The cat in the hat.", WordCharacter..] Funny enough, for the U.S. constitution example, vim, Word and OpenOffice report 7620 words instead of Mathematica's 7632. So WordCharacter.. seems not completely equivalent to other counting methods. Regards, Yves Gregory Lypny schrieb: > Hello everyone, > > Is this the simplest way to find the number of words in a string? > Seems a little complicated, and I can't seem to turn it into a > function because when I replace the string with the argument > placeholder myString_ I get an error message saying that a string is > expected in that spot. > > Length[ReadList[StringToStream["The cat in the hat."], Word]] > > Returns 5. > > Gregory >