【发布时间】:2017-01-21 03:42:17
【问题描述】:
我想在 PHP 中找到 2 个 URL 之间的共同模式。 我玩过https://gist.github.com/chrisbloom7/1021218,但在找到最长的匹配时就停止了,不考虑URL中存在的通配符。
例如这里有 2 个网址
- 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/
有谁知道我可以如何调整代码以使其正常工作或有更好的方法吗?
【问题讨论】:
标签: php regex url pattern-matching longest-substring