question on regular expressions

Sean Ross seandavidross at hotmail.com
Fri Dec 3 19:01:50 CET 2004


"Darren Dale" <dd55 at cornell.edu> wrote in message
news:coq8n8$san$1 at news01.cit.cornell.edu...
> I'm stuck. I'm trying to make this:
>
> file://C:%5Cfolder1%5Cfolder2%5Cmydoc1.pdf,file://C
> %5Cfolderx%5Cfoldery%5Cmydoc2.pdf
>
> (no linebreaks) look like this:
>
> ./mydoc1.pdf,./mydoc2.pdf
>
> my regular expression abilities are dismal. I won't list all the
> unsuccessful things I've tried, in a nutshell, the greedy operators are
> messing me up, truncating the output to ./mydoc2.pdf. Could someone offer
a
> suggestion?
>
> Thanks,
> Darren

from os.path import basename
import urllib

url = 'file://C:%5Cfolder1%5Cfolder2%5Cmydoc1.pdf'
print './%s'%basename(urllib.url2pathname(url))

HTH,
Sean






More information about the Python-list mailing list