Yoav wrote: > Don't think it will do much good. I need to get them from a file and > extract the last folder in the path. For example: > if I get "c:\dos\util" > I want to extract the string "\util"
like frederik says (I use '/' as I am using Unix): >>> import os >>> os.path.split ('c:/foo/bar') ('c:/foo', 'bar') >>> os.path.splitext ('c:/foo/bar') ('c:/foo/bar', '') >>> os.path.splitext ('c:/foo/bar.txt') ('c:/foo/bar', '.txt') or if you are really reluctant: >>> 'c:\\foo\\bar'.split ('\\') ['c:', 'foo', 'bar'] >>> 'c:\\foo\\bar'.split ('\\') [-1] 'bar' > Fredrik Lundh wrote: >> instead of struggling with weird REs, why not use Python's standard >> filename manipulation library instead? >> >> http://docs.python.org/lib/module-os.path.html >> >> </F> >> >> -- rafi "Imagination is more important than knowledge." (Albert Einstein) -- http://mail.python.org/mailman/listinfo/python-list