Regular expression - dot problem!

李政 fzhenglee23 at
Wed Jun 7 22:29:23 CEST 2006

  I've a problem with regular express(dot problem). I checked Python Library Reference, but i can't find any infomation that is useful . Nor did Google. 
  They have the same way: 
  It always works better. But my pattern string must be an argument of re.compile(). In this case, I can not use
  Here is my code. Bold text is where the problem is. Is there anyone know the right way to do this.
  def getLinkType(url, sitedomain):
    # get the domain which 'url' belongs to
    urldomain = urlparse4esa(url)[1]
    tmpsd = ''
    if re.compile('^www').match(sitedomain) is not None:
        tmpsd = sitedomain[4:]
    tmpsd.replace('.', '\.')        # it seems that it doesn't  work
    pattern = tmpsd + '$'        # this is my pattern string. 
                                              # Example: pattern ''
    if re.compile(pattern).match(urldomain) is not None:
        return INTERNAL_LINK    # match. url is internal link
        return EXTERNAL_LINK    # doesn't match. url is external link
  Alex, China

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list