search backward

Steven Bethard steven.bethard at gmail.com
Tue Jan 4 04:50:18 EST 2005


Robert wrote:
> I need to find the location of a short string in a long string. The
> problem however is that i need to search backward.
> 
> Does anybody know how to search in reverse direction?

How about str.rfind?

py> s = 'abc:def:abc'
py> s.rfind('abc')
8

Steve



More information about the Python-list mailing list