def convert_regex_to_flask_path(url_path):
 for token in [u'$']:
  url_path = url_path.replace(token, u'')
 def caller(reg):
  (match_name, match_pattern) = reg.groups()
  return u'<regex("{0}"):{1}>'.format(match_pattern, match_name)
 url_path = re.sub(u'\\(\\?P<(.*?)>(.*?)\\)', caller, url_path)
 if url_path.endswith(u'/?'):
  url_path = url_path.rstrip(u'/?')
 return url_path

def convert_regex_to_flask_path ( url_path ) : for token in [ u'$' ] : url_path = url_path . replace ( token , u'' ) def caller ( reg ) : ( match_name , match_pattern ) = reg . groups ( ) return u'<regex("{0}"):{1}>' . format ( match_pattern , match_name ) url_path = re . sub ( u'\\(\\?P<(.*?)>(.*?)\\)' , caller , url_path ) if url_path . endswith ( u'/?' ) : url_path = url_path . rstrip ( u'/?' ) return url_path
converts a regex matching url to one that can be used with flask .