Python Forum

Full Version: string index
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
Tesseract has a few methods to OCR prayer cards, and for a particular type of document,
I need to use a combination of two methods. It presents a problem, that I need to solve efficiently ,
to affect the processing time as little as possible.
It goes like this:
names = "johnmarypeterpauljohnaugustusemilianostevenandmanyotherwords" # one long string of words on the card
I want to find a particular combination, say name = "pauljohn" .
I can easily find out if it is in the names string (if name in names: )
Question:
If the statement is "True", I need to know the indexes of all it's corresponding letters in names.
"Brute force" is always possible, but there might be a more clever way that eludes me?
Paul

EDIT: don't bother, it's too simple. I thought you could only string.find() letters. You can string.find(strings)/ and get the index.