我想在 PHP 中找到 2 个 URL 之间的共同模式。我已经玩过https://gist.github.com/chrisbloom7/1021218但这在找到最长的匹配时停止,而不考虑 URL 中存在的通配符。
例如这里有 2 个 URL
- http://example.com/collections/dresses/products/dress.html
- http://example.com/collections/shoes/products/shoe.html
如果我在这些上运行函数,我的常见模式是
http://example.com/collections/
我正在寻找的是
http://example.com/collections/*/products/
有谁知道我可以如何调整代码以使其工作,或者有更好的方法吗?