Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. Pattern pattern = Pattern.compile("(\\+*)(\\d+)");
  2. Matcher matcher = pattern.matcher(ip);
  3. int cnt=0;
  4. String op="***-***-****";
  5.  
  6. matcher.find();
  7. cnt+=matcher.group(2).length();
  8. String countryCode=matcher.group(2);
  9. String plus="";
  10. System.out.println(matcher.group(1) +"<--->plus");
  11. if(matcher.group(1).length()>0)
  12. {
  13. plus="+";
  14. }
  15. while(matcher.find())
  16. {
  17.  
  18. cnt+=matcher.group(0).length();
  19.  
  20. }
  21. if(cnt>10)
  22. {
  23. cnt=cnt-10;
  24. // System.out.println("CC->"+ countryCode);
  25. countryCode=countryCode.substring(0,cnt).replaceAll("[0-9]", "*") +"-";
  26. }
  27. else
  28. countryCode="";
  29.  
  30. System.out.println(plus+countryCode + op);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement