Home  >  Article  >  Backend Development  >  将邮箱的某一段替换为*

将邮箱的某一段替换为*

WBOY
WBOYOriginal
2016-06-23 14:00:351879browse

将邮箱地址的第3 位到'@'之间的字符串替换为符号'*'   谢谢


回复讨论(解决方案)

echo preg_replace('/(?<=.{3}).+@/', '*@', 'username@mail.net');
use*@mail.net

$str ="12q2345qqqq667@qq.com";$sub = substr($str, 2,strpos($str,'@') -2);$len = strlen($sub);$replaceStr = str_repeat('*',$len);$newStr = str_replace($sub, $replaceStr, $str);var_dump($newStr);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn