I'd like to find the common pattern between 2 URLs in PHP. I've played around with https://gist.github.com/chrisbloom7/1021218 but that stops at the point of finding the longest match not accounting for wildcards that exist in URLs.
e.g. here are 2 URLs
- http://example.com/collections/dresses/products/dress.html
- http://example.com/collections/shoes/products/shoe.html
If I run the function over these, my common pattern is
http://example.com/collections/
What I'm looking for is
http://example.com/collections/*/products/
Does anyone know how I can adapt the code to make it work or is there a better way?