Dev Language/JAVA
숫자형식 포멧 방법
타카스 류지
2017. 7. 13. 15:31
//휴대폰
public static String makePhoneNumber(String Number) {
String regEx = "(\\d{3})(\\d{3,4})(\\d{4})";
if(!Pattern.matches(regEx, Number)) return null;
return Number.replaceAll(regEx, "$1-$2-$3");
}
//사업자번호
public static String makeNumber(String Number) {
String regEx = "(\\d{3})(\\d{2})(\\d{5})";
if(!Pattern.matches(regEx, Number)) return null;
return Number.replaceAll(regEx, "$1-$2-$3");
}
//법인번호
public static String makeNumber(String Number) {
String regEx = "(\\d{6})(\\d{7})";
if(!Pattern.matches(regEx, Number)) return null;
return Number.replaceAll(regEx, "$1-$2");
}