regular expression help

From: Date: Mon, 17 Sep 2001 23:59:11 +0000
Subject: regular expression help
Groups: php.general 
Request: Send a blank email to php-general+get-67662@lists.php.net to get a copy of this message
hi all, I have some user-supplied text on a content driven site. I am allowing <A> tags inside the main text, BUT I want any links to external sites (not on the chosen domain) to include a ' TARGET="_new" ' element. So, <A HREF="http://www.mydomain.com/mypage.php">something</a> is fine <A HREF="http://www.yourdomain.com/yourpage.php">something</a> is wrong <A HREF="http://www.yourdomain.com/yourpage.php" TARGET="_new">something</a> is fine And of course there are all the variants with and without the www, and with and without sub directories and pages. I'[d also like to make sure the dopey people have put a close tag in. I've got a few ideas on how it might be done, but I need to do it the right way, avoiding slight human errors etc. Has anyone got something written, or can point me in the right direction? Justin French

« previous php.general (#67662) next »