본문 바로가기

Java&JSP

[JAVA] matches 함수를 이용해 특수문자 체크

자바에서 특수문자를 확인하고 싶을때 matches 함수를 이용하여 확인해보자.

String str = "가나다라!!";

boolean result = str.matches ("[0-9|a-z|A-Z|ㄱ-ㅎ|ㅏ-ㅣ|가-힝]*");

result 값 확인 true , false

'Java&JSP' 카테고리의 다른 글