searching backwards in a string

Mark Zöltsch laalien at
Tue Feb 12 16:27:31 CET 2002


> Short answer:  Reverse the string first.

I'm new to this python stuff and to this newsgroup too..
but why you don't use 'rfind' instead of 'find'?
I think that's much easier...

somthing like:

import string

str = 'ac ab ab ac'
res = string.rfind(str, 'ac', 0, len(str))

print 'last position :', res

PS sorry for bad english and grammar

More information about the Python-list mailing list