Regular expression / php to change url format
===

I have been given the task of updating a rather ugly, dated site, that has info on hundreds of cities, all of which sit on their own subdomain, for example:

> london.sitedomain.com

The plan is to get rid of all these subdomains and set the site up properly as pages, in this format:

> sitedomain.com/london

Unfortunately, there is a mass, hardcoded list making up a dropdown menu, looking something like this (but with hundreds):


    <a href="http://sydney.sitedomain.com">Sydney</a>
    <a href="http://auckland.sitedomain.com"> Auckland</a>
    <a href="http://melbourne.sitedomain.com"> Melbourne</a>
    <a href="http://perth.sitedomain.com"> Perth</a>
    <a href="http://wellington.sitedomain.com"> Wellington</a>

If I set this huge list up as a php string, is there a decent way to change, in bulk, every subdomain substring into the correct format, as stated above? Or is there a better solution you can think of?

