question on regular expressions

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

"Darren Dale" <dd55 at> wrote in message
news:coq8n8$san$1 at
> 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
> suggestion?
> Thanks,
> Darren

from os.path import basename
import urllib

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


More information about the Python-list mailing list