FWIW this will find all occurrences of a word in a string. Also note that if you are looking for "the" it will give a hit for "then". If you only want the word, you have to search with spaces added, " the " -assuming string.lower() and that punctuation is removed
found=the_string.find(word)
while found > -1:
print word, "found at location", found
found=the_string.find(word, found+1)
woooee
Nearly a Posting Maven
2,454 posts since Dec 2006
Reputation Points: 777
Solved Threads: 714
You should really start a new thread of your own!
The string function find() can find a subtext within a larger text, as will re.findall(). The advantage of find() is that it will give you the location in the form of an index.
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
Ah, the pros and cons on posting on an old thread.
If you are interested in a regex solution, I would start a new thread and put regex in the title.
sneekula
Nearly a Posting Maven
2,427 posts since Oct 2006
Reputation Points: 961
Solved Threads: 212