๋ฐ์ํ
ํด๋ํฐ ๋ฒํธ๋ฅผ asterisk(*)๋ก ์ํธํํ๋ ์ฝ๋์ ๋๋ค.
/**
* encrypt number in text
*
* maskingCallNumber
*
* @param str
* @return String
*/
public static String maskingCallNumber(String str){
String replaceString = str;
String matchedStr ="";
String pattern ="(\\d{2,3})-?(\\d{3,4})-?(\\d{3,4})";
Matcher matcher = Pattern.compile(pattern).matcher(str);
if(matcher.find()){
StringBuffer br = new StringBuffer();
for(int i = 1 ; i<=matcher.groupCount(); i++){
matchedStr = matcher.group(i);
for(int j = 0 ; j <matchedStr.length();j++){
br.append("*");
}
if(i !=matcher.groupCount()){
br.append("-");
}
}
replaceString =matcher.replaceAll(br.toString());
}
return replaceString;
}