code: def uri_to_regexp(self, uri):
          
          def _convert(elem, is_last):
              if not re.match('^{.*}$', elem):
                  return elem
              name = elem.replace('{', '').replace('}', '')
              if is_last:
                  return '(?P<%s>[^/]*)' % name
              return '(?P<%s>.*)' % name
  
          elems = uri.split('/')
          num_elems = len(elems)
          regexp = '^{}$'.format('/'.join([_convert(elem, (i == num_elems - 1)) for i, elem in enumerate(elems)]))
          return regexp
docs: converts uri w/ placeholder to regexp
            '/cars/{carName}/drivers/{DriverName}'
          -> '^/cars/.*/drivers/[^/]*$'
  
            '/cars/{carName}/drivers/{DriverName}/drive'
          -> '^/cars/.*/drivers/.*/drive$'