searching backwards in a string
Mark McEahern
marklists at mceahern.com
Tue Feb 12 10:11:51 EST 2002
Sorry, the sample I posted doesn't correctly adjust for the difference
between the length of the word and the last index of the word. Replace
this:
> # Express location relative to original orientation of word.
> start = len(s) - m.start()
with:
# Express location relative to original orientation of word.
lastIndex = len(s) - 1
start = lastIndex - m.start()
print "%s found backwards in %s at %d." % (pattern, s, start)
// mark
More information about the Python-list
mailing list