Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Pattern pattern = Pattern.compile("(\\+*)(\\d+)");
- Matcher matcher = pattern.matcher(ip);
- int cnt=0;
- String op="***-***-****";
- matcher.find();
- cnt+=matcher.group(2).length();
- String countryCode=matcher.group(2);
- String plus="";
- System.out.println(matcher.group(1) +"<--->plus");
- if(matcher.group(1).length()>0)
- {
- plus="+";
- }
- while(matcher.find())
- {
- cnt+=matcher.group(0).length();
- }
- if(cnt>10)
- {
- cnt=cnt-10;
- // System.out.println("CC->"+ countryCode);
- countryCode=countryCode.substring(0,cnt).replaceAll("[0-9]", "*") +"-";
- }
- else
- countryCode="";
- System.out.println(plus+countryCode + op);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement