How to find all the same words in a text?

Neil Cerutti horpner at yahoo.com
Sun Feb 11 08:38:54 EST 2007


On 2007-02-10, Johny <python at hope.cz> wrote:
> I need to find all the same words in a text .
> What would be the best idea  to do that?
> I used string.find but it does not work properly for the words.
> Let suppose I want to find a number 324 in the  text
>
> '45  324 45324'
>
> there is only one occurrence  of 324 word but string.find()   finds 2
> occurrences  ( in 45324 too)
>
> Must I use regex?
> Thanks for help

The first thing to do is to answer the question: What is a word?

The second thing to do is to design some code that can find
words in strings.

The last thing to do is to search those actual words for the word
you're looking for.

-- 
Neil Cerutti



More information about the Python-list mailing list