/**
* 实际替换动作
*
* @param str str
* @return
*/
public static String replaceAction(String str) {
if(isEmpty(str)){
return "";
}
String afterReplaced = "";
int nameLength = str.length();
if (nameLength < 3 && nameLength > 0) {
if (nameLength == 1) {
afterReplaced = "*";
} else {
afterReplaced = str.substring(0,1)+"*";
}
} else {
Integer num1, num2, num3;
num2 = (new Double(Math.ceil(new Double(nameLength) / 3))).intValue();
num1 = (new Double(Math.floor(new Double(nameLength) / 3))).intValue();
num3 = nameLength - num1 - num2;
String star = org.apache.commons.lang3.StringUtils.repeat("*", num2);
afterReplaced = str.replaceAll("(.{" + num1 + "})(.{" + num2 + "})(.{" + num3 + "})", "$1" + star + "$3");
}
return afterReplaced;
}