본문 바로가기
근무일지

[Regex/정규표현식] 일본어, 중국어, 한국어 정규표현식

by Developer RyanKim 2020. 5. 18.

 

Regex 정규표현식 일본어 중국어 한국어 포함


댓글내용으로 한국어, 영어, 일본어, 중국어 판별이 필요했습니다.

여러 레퍼런스를 참고하였고 테스트 결과 가장 정확도가 높은 표현식을 기록합니다.

#한글,자음 포함 일어,한자 미포함 -> ko
select * from comment
and comment_msg not regexp '/[ぁ-ゔ]+|[ァ-ヴー]+[々〆〤]+/u'
and comment_msg not regexp '[一-龥]'
and (comment_msg regexp '[가-힇]'
or comment_msg regexp '[ㄱ-ㅎㅏ-ㅣ]');

#일본어 포함 한글 미포함 -> ja
select * from comment
and comment_msg not regexp '[가-힇]'
and comment_msg not regexp '[ㄱ-ㅎㅏ-ㅣ]'
and comment_msg regexp '[ぁ-ゔ]+|[ァ-ヴー]+[々〆〤]+/u';

#한자 포함 한글미포함 일어미포함 -> zh
select * from comment
and comment_msg not regexp '[가-힇]'
and comment_msg not regexp '[ㄱ-ㅎㅏ-ㅣ]'
and comment_msg not regexp '[ぁ-ゔ]+|[ァ-ヴー]+[々〆〤]+/u'
and comment_msg regexp '[一-龥]';

# 알파벳포함 한글,자음,일어,한자 미포함
 -> en
select * from comment
and comment_msg not regexp '[가-힇]'
and comment_msg not regexp '[ㄱ-ㅎㅏ-ㅣ]'
and comment_msg not regexp '[一-龥]'
and comment_msg regexp '[a-zA-Z]';

 

댓글