I am having a bit of trouble with this. I am a beginner with regular expressions, so please bear with me. What I am trying to do is match
Code:
http://www.mytravelsite.com/states/cities/thiscity/
to
Code:
http://www.inchicago.com/
so that when I pass the url through my object
Code:
<a href="http://www.mytravelsite.com/states/cities/thiscity/dir0-6/whateverpageisindexed.shtml">title</a>
becomes a clickable link to thats file location that looks like
Code:
<a href="http://www.inchicago.com/dir0-6[whicheverisreturned]/whateverpageisindexed.shtml">title</a>
The code
Code:
$test="http://www.mytravelsite.com/states/cities/thiscity/0/apage.shtml";
preg_match('/\/[^\/]*?\/(?!.*?\/).*/',$test, $extract);
echo "http://www.inchicago.com$extract[0]";
returns
Code:
http://www.inchicago.com/0/apage.shtml
but the numbered dir may fluctuate as well as the returned page. Hopefully that makes sense. How can I make
Code:
http://www.mytravelsite.com/states/cities/thiscity/
resolve to
Code:
http://www.inchicago.com/
but leave
alone so that it will be flexible?
Bookmarks