In article <Riqkc.36277$h44.5382158@stones.force9.net>,
ng@lycaus.plusYOURSHIT.com (Dariusz) wrote:
[color=blue]
> I am having problems with trying to remove some tags using PHP. What I
> want is to perform a search and replace on a URL, so if someone tried to
> put a URL into a guestbook database, instead of the user inputting a
> link as:
>
> <a href="http://whatever.com">visit me</A>
>
> It goes into the database as:
>
>
http://whatever.com[/color]
[...]
[color=blue]
> I've made an attempt at preg_replace() but it's difficult to get head
> around trying to write a pattern.[/color]
First attempt (I checked that it works on your example, I didn't try
anything else):
$href = '<a href="http://whatever.com">visit me</A>';
$unclickable_url = preg_replace('!<a.+?href="([^"]+)".*?</a>!i', "$1",
$href);
echo $unclickable_url;
I'm sure this is not good enough yet. Feel free to improve, anyone.
JP
--
Sorry, <devnull@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.