The best answer depends on your definition of 'word'. You probably mean a string of characters that you consider as 'word characters'. Under this definition, you probably want a regular expression. Perl's character class \w is almost certainly what you need to match those characters. Although it is not necessary, I also recommend that you verify that your regex match succeeds before using its result.
UPDATE: Note that the code that this would require is the same as scorpio17's except for the regex. He implements a different definition of 'word'.