Convert simplified domain expression to regular expression

def simToReg(self, sim):
        """Convert simplified domain expression to regular expression"""
        # remove initial slash if present
        res = re.sub('^/', '', sim)
        res = re.sub('/$', '', res)
        return '^/?' + re.sub('\*', '[^/]+', res) + '/?$'