I'm trying to capture the middle part of a URL, that contains a conditional ending:
A URL can be of two sorts:
/a/b/(part/needed)
/a/b/(part/needed)/page/#
here's the regexp I use:
preg_match('@/a/b/(.*)(/page/\d)?@i', '/a/b/some/text/page/1', $matches);
returns
0=>"/a/b/some/text/page/1",
1=>"some/text/page/1"
It's ok but it includes the conditional ending which I don't want!
Can someone tell me how to not include the conditional string ending in it but still match when the last segment is present or absent?