I'm using a chat bot script, if a user name was test@test.com
the bot will reply @ <a href= mailto:test@test.com>test@test.com</a>
with a mailto link. I want the reply to be only test@test.com
without the link, I tried preg_replace
and str_replace
but I don't really know the exact code to use, I've tried the following but didnt work !
$name = preg_replace('/<a href="([^<]*)">([^<]*)<\/a>/', '', $name);
The whole code I'm using for replacements is this:
$name = str_replace (chr(0xc2).chr(0xa0), "_", $name);
$name = str_replace ("'", "", $name);
$name = str_replace (""", '"', $name);
$name = str_replace ("&", "&", $name);
$name = str_replace ("<", "", $name);
$name = str_replace (">", "", $name);
$name = str_replace ("&", "_", $name);
$name = str_replace ("*", "_", $name);
$name = preg_replace('/[^ \p{L}\p{N} \@ \_ \- \.\#\$\&\!]/u', '', $name);
$name = preg_replace('/<a href="([^<]*)">([^<]*)<\/a>/', '', $name);