php - Replace username part in email addresses into asterisks -
how can convert username in email addresses asterisks. first , last letter in username stay , rest replaced (*).
example:
mhyunf@gmail.com into
m****f@gmail.com
you can using arounds.
/(?!^).(?=[^@]+@)/ (?!^)negative behind. checks if character not preceded start of string. ensures first character not selected..matches single character.(?=[^@]+@)positive ahead. ensures single character matched followed other@( ensured[^@]) ,@
example
preg_replace("/(?!^).(?=[^@]+@)/", "*", "mhyunf@gmail.com") => m****f@gmail.com
Comments
Post a Comment