티스토리 뷰
유효성 검사
이메일
public static boolean isEmail(String email) {
if (email==null) return false;
boolean b = Pattern.matches(“[\\w\\~\\-\\.]+@[\\w\\~\\-]+(\\.[\\w\\~\\-]+)+”,email.trim());
return b;
}
휴대폰
public static boolean isValidCellPhoneNumber(String cellphoneNumber) {
boolean returnValue = false;
Log.i(“cell”, cellphoneNumber);
String regex = “^\\s*(010|011|012|013|014|015|016|017|018|019)(-|\\)|\\s)*(\\d{3,4})(-|\\s)*(\\d{4})\\s*$”;
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(cellphoneNumber);
if (m.matches()) {
returnValue = true;
}
return returnValue;
}
일반 전화번호
public static boolean isValidPhoneNumber(String phoneNumber) {
boolean returnValue = false;
String regex = “^\\s*(02|031|032|033|041|042|043|051|052|053|054|055|061|062|063|064|070)?(-|\\)|\\s)*(\\d{3,4})(-|\\s)*(\\d{4})\\s*$”;
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(phoneNumber);
if (m.matches()) {
returnValue = true;
}
return returnValue;
}
'언어 > ANDROID' 카테고리의 다른 글
| [Android] EditText에 phon 하이픈(-) 자동 넣기 (0) | 2016.09.01 |
|---|---|
| [Android] Intent 값 전달 (0) | 2016.09.01 |
| [Android] 안드로이드 생명 주기 (0) | 2016.09.01 |
| [Android] 문자열을 int로, int 문자열로 (0) | 2016.09.01 |
| [Android] Switch 사용하기 (0) | 2016.09.01 |
- Total
- Today
- Yesterday
- UTF-8
- nsis
- 스프링
- Controller
- 자바
- mybatis
- 사용
- Android
- 안드로이드
- jdbc
- iNT
- 클래스
- 음식
- 어노테이션
- Create
- synchronized
- 하기
- 생성
- Server
- java
- 종류
- Default
- 연결
- Class
- Delete
- spring
- mysql
- 라이브러리
- js
- jsp
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |