모바일/Android_Java
[Android] 특수문자 제거
필경이야
2022. 2. 16. 13:16
trim()과 replaceAll()을 사용하여도 제거되지 않는 특수문자가 있을 경우..
public static String StringReplace(String str){
String match = "[^\uAC00-\uD7A3xfe0-9a-zA-Z\\s]";
str =str.replaceAll(match, "");
return str;
}
한글유니코드(\uAC00-\uD7A3), 숫자 0~9(0-9), 영어 소문자a~z(a-z), 대문자A~Z(A-Z), 공백(\s)
를 제외한(^) 단어일 경우 체크
출처:https://jang8584.tistory.com/97