string.find first before location
phddas at yahoo.com
Tue May 2 12:42:54 CEST 2006
Peter Otten <__peter__ at web.de> writes:
> Gary Wessle wrote:
> > I have a string like this
> > text = "abc abc and Here and there"
> > I want to grab the first "abc" before "Here"
> > import string
> > string.find(text, "Here") # <type int>
> > I am having a problem with the next step.
> These days str methods are preferred over the string module's functions.
> >>> text = "abc abc and Here and there"
> >>> here_pos = text.find("Here")
> >>> text.rfind("abc", 0, here_pos)
and what about when python 3.0 is released and those depreciated
functions like find and rfind are not supported. is there another
solution which is more permanent?
More information about the Python-list