• Uncategorized
  • 0

Dreamweaver Regular Expression to find and replace URL string

If I have a page with say 100 URLs that I need to change, I can do this one of two ways.
1) Seek out every link in the code and delete the text and replace with what I need to
OR 2) Use a regular expression in dreamweaver

Lets say I have a URL that looks like this
a href=”http://imwebdev.com/posts/post.html” Title =”Post”>
a href=”http://imwebdev.com/posts/anotherpost.html” Title =”Another post”>
a href=”http://imwebdev.com/posts/yetanotherpost.html” Title =”Yet Another post”>

Now I would like to change the entire url but maintain all the other information such as the Title attribute. I have 100 of these links to change, and I dont want have to go through and manually change each link.

Here is what I can do
a href=”/posts/([^<]*)” Title =”([^<]*)”
a href=”newurl.php” title=”$1″

This will replace the entire http://imwebdev.com/posts/ path and still maintain the Title parameter.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *