Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Number of Words in a String

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102483] Number of Words in a String
  • From: Gregory Lypny <gregory.lypny at videotron.ca>
  • Date: Tue, 11 Aug 2009 04:02:50 -0400 (EDT)

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


  • Prev by Date: Re: Re: Re: error with Sum and Infinity
  • Next by Date: Re: help import latex file with mathematica 7
  • Previous by thread: Re: video on Presentations by Williams
  • Next by thread: Re: Number of Words in a String