Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

Find and replace url using regular expression

Posted 27 Sep 2006 16:12:47
1
has voted
27 Sep 2006 16:12:47 John D posted:
I am new to reg expressions and would like to write a regex for a .html page I am working on in DW. I want the regex to find every http link (a href= ) that contains .org. Once it finds every link that contains .org I want to then remove ( exit.asp?url= ) that precedes it as well as add the attribute ( target="_blank" ) to the (a href=) tag.

This basically will find all instances where I am calling my .asp page that lets the user know they are exiting the main site for an outside source and eliminate this page as long as the link they are clicking is within the original site. Otherwise I call my exit.asp page which notifies the user they are leaving.

Example:

Look for this type of tag (one where the link contains .org):
a href="exit.asp?url=myorgwebsite.org/myorg"> Link 1

Replace with this (removes the "exit.asp?url=", but adds target="_blank" attribute):
a href="myorgwebsite.org/myorg" target="_blank"> Link 1



Thanks in advance.

JD

Edited by - Tabrizz on 27 Sep 2006 19:06:49

Reply to this topic