How do I remove all email addresses and links from a string and replace them with \"[removed]\"
There are a lot of characters valid in the first local part of the email (see What characters are allowed in an email address?), so these lines would replace all valid email addresses:
\1', $t);
# replace urls:
a='A-Za-z0-9\-_';
$t = preg_replace("/[htpsftp]+[:\/\/]+[$a]+\.+[$a\.\/%&=\?]+/i", '[removed]', $t);
This will cover most valid email addresses, be informed: removing really only all valid email addresses is a bit more complex (see How to validate an email address using a regular expression?)