I have a string with some text and some URLs in it. My goal is to remove the following from the string:
$removeThis = array('http://', 'https://', 'www.', '.com', '.net');
BUT ONLY IF the word to be removed doesn't start with: http://good.com, http://www.good.com, https://good.com, or https://www.good.com.
In other words, I want to remove http|s|www.|.com|.net parts from the string (but only if they don't belong to good.com domain).
INPUT:
$string='Hello world, this is spamming: www.spam.com, spam.net, https://spam.com, https://spam.com/tester. And this is not spam so do not touch it: http://www.good.com/okay, http://good.com, and also https://good.com/well';
RESULT SHOULD BE:
Hello world, this is spamming: spam, spam, spam, spam/tester. And this is not spam so do not touch it: http://www.good.com/okay, http://good.com, and also https://good.com/well
I think preg_replace is needed here..