[Zope] easy regular expression for URL fixup

Ed Colmar ed@greengraphics.net
Wed, 6 Mar 2002 14:51:46 -0800


Hey Tom

Thanks for the reply...

Those backslashes are for escaping the special characters (\w and .).  Do
they need to be doubled in this case?

This still is not working for me

###  I want: http://www.the.net/bigfolder/ ###
import re
url = "http://www.the.net/bigfolder/somepage.html"
htmlfile = re.compile("/\\w*\\.html")
m = htmlfile.match(url)
if m:
   folder_url = htmlfile.sub(url, "/")


I'm also trying different variations to try and get a match.  None of these
are working either:
htmlfile = re.compile("/.*$")   (this one should really be working yes?)
htmlfile = re.compile("[a-z]*$")
htmlfile = re.compile("\w*$")

the only match I can make is this (which will match anything):
htmlfile = re.compile(".*$")