Need Search & Replace Help (Regex Newbie)
Posted: Tue May 12, 2009 4:35 pm
I'm using Dreamweaver's search-and-replace function to convert a website that includes hundreds of pages with links to pages focusing on the world's nations.
Consider the following links:
Notice that they're exactly the same except for the two characters following the domain name (sp and zi) and the names visitors see (Spain and Zimbabwe). I want to replace the two characters with the country's name, and I also want to insert the country's name in the title attribute, so the finished URL's will look like this:
Does anyone know how to make a regex script like that?
One more detail...can you adjust it so that spaces in place names that consist of more than one word are replaced by underscores in the link, as follows? (If not, don't worry about it. I can probably fix that with a second regex that simply replaces spaces with underscores in links.)
And if my original request is too difficult, I'd settle for a regex that converts this...
to this...
...or something similar. If I could merely replicate the place name, with different characters after each occurrence, then I could fill in the blanks with a series of search and replace operations.
I'm playing with a software program called RegExhibit and have learned that I can match everything between the tags with this regular expression: title="".*>
However, I don't have a clue about manipulating the data I've matched.
Thanks!
Consider the following links:
Code: Select all
<td><a href="http://www.geoworld.org/sp" title="">Spain</a></td>
<td><a href="http://www.geoworld.org/zi" title="">Zimbabwe</a></td>
Code: Select all
<td><a href="http://www.geoworld.org/Spain" title="Spain">Spain</a></td>
<td><a href="http://www.geoworld.org/Zimbabwe" title="Zimbabwe">Zimbabwe</a></td>
One more detail...can you adjust it so that spaces in place names that consist of more than one word are replaced by underscores in the link, as follows? (If not, don't worry about it. I can probably fix that with a second regex that simply replaces spaces with underscores in links.)
Code: Select all
<td><a href="http://www.geoworld.org/United_Kingdom" title="United Kingdom">United Kingdom</a></td>
Code: Select all
<td><a href="http://www.geoworld.org/sp" title="">Spain</a></td>
Code: Select all
<td><a href="http://www.geoworld.org/sp" title="">Spain</a>Spain2Spain3</td>
I'm playing with a software program called RegExhibit and have learned that I can match everything between the tags with this regular expression: title="".*>
However, I don't have a clue about manipulating the data I've matched.
Thanks!