Image

Imageangelina_zooma wrote in Imagephp 😛determined

eregi_replace a link

Hi everybody.. I have an issue that's driving me crazy. I'm trying to remove links from user submitted content (on the output) and I can't seem to get one last thing. All my filters work so far except is they just enter something like "sample.ca" right at the end of the string.

I have to admit I don't fully understand what all is going on here, but this is what I've got:

$text = "sample.ca is what I'm testing. Test sample.ca";

$text = eregi_replace("([[:alnum:]]+\.ca)[[:space:]|[:punct:]]", " [Link Removed] ", $text);

will output:

[Link Removed] is what I'm testing. Test sample.ca

I've got a separate filter to get rid of ones starting with http:// or www. which both seem to do their jobs properly no matter where in the string the link falls, but I can't seem to figure out what I can use from those to make this one work.

// Remove http:// links
$text = eregi_replace("([[:alnum:]]+://([.]?[a-z0-9_/-])*)", " [Link Removed] ", $text);

// Remove www. links
$text = eregi_replace("(www\.+([.]?[a-z0-9_/-])*)", " [Link Removed] ", $text);


ETA: Solution is in the comments, many thanks Imagedigitalsidhe !