0

The question is fairly straight forward. I want to remove text links from posts.

$post = $_POST['text'];
//something to remove any instance of a text link

Please understand I am not trying to remove

<a href="...">text</a>

Rather I just want any plaintext links removed

This is an example. All this is okay but I want the following stripped:
http://someurl.com/... or http://www.someurl.com/...

Here is what I have been trying:

    $post = preg_replace(@^(http\:\/\/|https\:\/\/)?([a-z0-9][a-z0-9\-]*\.)+[a-z0-9][a-z0-9\-]*$@i, '', $posted);

I am getting error: unexpected '^', if I remove the ^ then I get an unexpected ':' error.

Bruce
  • 1,039
  • 1
  • 9
  • 31

0 Answers0