Jump to content

removing links in text


jorley

Recommended Posts

Hi guys, I have a network that I am working on and people keep posting links to their pesonal sites even though its against the terms. I need to write a function to remove these links. The problem is that sometimes they put in www, sometime http, sometimes spaces of whatever they can to get past it. Removing people that do this is something we are trying to avoid. Lastly, when posting it in someplaces it removes the tags in others it keeps it so the <a isnt always there. I am assuming we are talking regex which I have been using but I cant figure this one out.

 

Can anyone point me in the right direction? I just want to replace them with a few characters to hokd its place but not show it.

Link to comment
https://forums.phpfreaks.com/topic/192348-removing-links-in-text/
Share on other sites

preg_replace('/<a.*<\/a>/U', '', $string); // remove: <a(any number of characters)</a> from $string

 

not sure how to remove other urls like: sub.domain.net where sub, domain and net can all be varying. you will need one of the real regexp gurus here to help with that ;)

Thanks Catfish. I tried it out and it removes the link which is what I need. There will always be work arounds but i figure if someone goes through the process of creating a work around then I will remove them from the site because at that point its blatant.  Thanks again.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.