Quantcast
Viewing all articles
Browse latest Browse all 9

masking of email address in java

I am trying to mask email address with "*" but I am bad at regex.

input : nileshxyzae@gmail.comoutput : nil********@gmail.com

My code is

String maskedEmail = email.replaceAll("(?<=.{3}).(?=[^@]*?.@)", "*");

but its giving me output nil*******e@gmail.com I am not getting whats getting wrong here. Why last character is not converted?Also can someone explain meaning all these regex


Viewing all articles
Browse latest Browse all 9

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>