By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,171 Members | 776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,171 IT Pros & Developers. It's quick & easy.

search backward

P: n/a
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?
Thanks,
Robert
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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?

"foofoo".find("foo") 0 "foofoo".rfind("foo") 3 "foofoo".index("foo") 0 "foofoo".rindex("foo")

3

--
--------------------------------------------------------------------
Aaron Bingham
Application Developer
Cenix BioScience GmbH
--------------------------------------------------------------------

Jul 18 '05 #2

P: n/a
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
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.