Python: Convert format string to regular expression,print(pattern.match('something/foo-en-gb/file.txt').groupdict())