'Return a regular expression with named groups for each wildcard.'

def _compile_pattern(self, rule):

    out = ''
    for (i, part) in enumerate(self.syntax.split(rule)):
        if ((i % 3) == 0):
            out += re.escape(part.replace('\\:', ':'))
        elif ((i % 3) == 1):
            out += (('(?P<%s>' % part) if part else '(?:')
        else:
            out += ('%s)' % (part or '[^/]+'))
    return re.compile(('^%s$' % out))
