Hey guys - Does anyone have a function (or know where I can find one) to find URLs posted in strings? If I had a comment submitted as a string, for instance, I'm trying to prevent it being displayed (or edit it) if it contains a URL / email / web address etc etc. I suppose it'd be some sort of reg ex, I just really, really don't want to sit down and figure it out... Much appreciated if you can help... ben
$raw= "Some text, http://digitalpoint.com"; $filtered = preg_replace("/(http:\/\/[^\s]+)/", "<a href=\"$1\">$1</a>", $raw); echo $filtered; PHP: This will replace http://digitalpoint.com with <a href="http://digitalpoint.com">http://digitalpoint.com</a> $raw= "Some text, http://digitalpoint.com"; $filtered = preg_replace("/(http:\/\/[^\s]+)/", "", $raw); echo $filtered; PHP: And this will remove the link completely.