regular expression question: last occurence

Gerrit Holl gerrit.holl at pobox.com
Sat Jun 12 18:02:42 CEST 1999


Hello all,

I want to get the _last_ occurence of some string in some other string. What
I want exactly, is having the current directory (for example,
/home/gerrit/linuxgames/links/)
and than put everything after the last "/linuxgames" in a string. But when
someone is in the directory "/home/gerrit/linuxgames/cvs/linuxgames", my current
regexp is getting /cvs/linuxgames, and that's not what I want. Now, I have:

currentdir = os.getcwd()
mo = re.search('/linuxgames', currentdir)
eind = mo.end()
subdir = currentdir[eind:] + '/'

But that doesn't solve my problem.

kind regards,
Gerrit.


-- 
The Dutch Linuxgames website.		De Nederlandse Linuxgames pagina.
Everything about games on Linux.	Alles over spelletjes onder Linux.
Site address:				http://linuxgames.nl.linux.org
Personal homepage:			http://nl.linux.org/~gerrit/




More information about the Python-list mailing list