PHP port of https://github.com/MM56/path-to-regexp