Quantcast
Channel: Masking Email address along with domain using regex - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Masking Email address along with domain using regex

$
0
0

The requirement is as below:

Input: rajani@gmail.comOutput: r****i@*****.com

I tried below two regex's but I could not able to mask the gmail(domain name). Kindly help me on this.

String masked_email_Address2=email_Address.replaceAll("(?<=.{1}).(?=[^@]*?.@)", "*");

Output received as r****i@gmail.com

I searched in stack overflow on this, I got the below regex but it does not produce the correct result:

String masked_email_Address1=email_Address.replaceAll("\\b(\\w)[^@]+@\\S+(\\.[^\\s.]+)", "$1***@****$2");

Output received as: r***@****.com -- One star(*) is missed between R&@.


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles



Latest Images