I'm trying to using RegEx to hide email addresses, except for the first two characters and the email domain.
The function, in that case, is replacing the characters that I want to keep.
email.replace(/^[A-Za-z]{2}/, "**" ).replace(/@[^:]*/, "**" )
What I get: [email protected] > **ail**
Expected: em***@domain.com
Anyone here who knows how can I change my RegEx to get the expected result?
Thanks!
"[email protected]".replace(/(.{2})(.*)(?=@)/, '$1*')
.