我正在使用聊天机器人脚本,如果用户名是机器人将使用 mailto 链接test@test.com
回复 @ 。<a href= mailto:test@test.com>test@test.com</a>
我希望回复只有test@test.com
没有链接,我试过了preg_replace
,str_replace
但我真的不知道要使用的确切代码,我试过以下但没用!
$name = preg_replace('/<a href="([^<]*)">([^<]*)<\/a>/', '', $name);
我用于替换的整个代码是这样的:
$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);