String s = "msdgsalasdasdehi@gmail.com";
int atIndex = s.indexOf("@");
String localPart = String.format("%-" + atIndex + "s", s.substring(0, 4)).replaceAll("\\s", "*");
String domainPart = s.substring(atIndex);
System.out.println(localPart + domainPart);
No comments:
Post a Comment