Check if string contains CJK characters (Chinese)

I need to check if a string contains Chinese characters. After searching, I found that I need to look at the regex on this pattern \u31C0-\u31EF , but I can't get the regex to work.

Has anyone experienced such a situation? Is the regular expression correct?

+1
java android string regex
Feb 26 '14 at 17:23
source share
1 answer

As discussed here , in Java 7 (i.e. the regex compiler meets the RL1.2 property requirement from UTS # 18 Unicode Regular Expressions ), you can use the following regular expression to match the Chinese (well, CJK) character:

 \p{script=Han} 

which can simply be replaced

 \p{Han} 
+2
Feb 26 '14 at 17:34
source share



All Articles