This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (string.trim().length() > 0){ | |
// true | |
} | |
if (string.matches(".*\\w.*")) { | |
// true | |
} |
첫번째 : trim 으로 공백을 모두 없앴을때 length 가 0 일때 true
두번째 : /w 로 문자열에 문자가 포함되었는지를 체크, 이 방법은 특수문자만으로 이루어진 글일때 역시 false 를 반환한다
ex) #$@! = false
두번째 : /w 로 문자열에 문자가 포함되었는지를 체크, 이 방법은 특수문자만으로 이루어진 글일때 역시 false 를 반환한다
ex) #$@! = false
댓글 없음:
댓글 쓰기