RE Despair - help required

Sion Arrowsmith siona at chiark.greenend.org.uk
Thu Aug 25 11:09:00 EDT 2005


In article <430dcea0$1 at news.bezeqint.net>, Yoav  <yoav_artzi at il.vio.com> wrote:
>Fredrik Lundh wrote:
>> "Yoav" wrote:
>>>I am trying the following:
>>>
>>>re.search(r'\\[^"\\]+(?=("?$))', "c:\ret_files")
>> 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
>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"

Did you actually look at the docs Fredrik pointed you at? Did you,
in particular, notice os.path.basename, which does (almost) exactly
what you want?

-- 
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |    -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump



More information about the Python-list mailing list