Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
string index
#1
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.
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020