emoji 유무 check

Lee HyeongJong·2022년 10월 19일
0

안드로이드

목록 보기
18/43

1. 코드

String text1 = "🥰🤯";
String text2 = " ♡♥☆★가나다ABCabc123!@#";

Pattern rex = Pattern.compile("[\\x{10000}-\\x{10ffff}\ud800-\udfff]");

Matcher rexMatcher1 = rex.matcher(text1);
Matcher rexMatcher2 = rex.matcher(text2);

System.out.println("text1 이모지 포함되어 있는가? : " + rexMatcher1.find());
System.out.println("text2 이모지 포함되어 있는가? : " + rexMatcher2.find());

결과

text1 이모지 포함되어 있는가? : true
text2 이모지 포함되어 있는가? : false

이모지 있을 시 true, 없을 시 false로 나타남

참고 : https://cmelcmel.tistory.com/m/113

profile
코딩을 시작해보자

0개의 댓글