Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public String maskPII(String S) {
- String s = S.toLowerCase();
- if (s.contains("@")) {
- int index = s.indexOf("@");
- String str = s.substring(0,index);
- return str.substring(0, 1)
- + "*****" + str.substring(str.length() - 1, str.length())
- + s.substring(index);
- } else {
- s = s.replace("+", "");
- s = s.replace("-", "");
- s = s.replace("(", "");
- s = s.replace(")", "");
- s = s.replace(" ", "");
- if (s.length() == 10)
- return "***-***-" + s.substring(6);
- else if(s.length() == 11)
- return "+*-***-***-" + s.substring(7);
- else if(s.length() == 12)
- return "+**-***-***-" + s.substring(8);
- else
- return "+***-***-***-" + s.substring(9);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement