Java examples for java.lang:String Unicode
return true if any CJK characters appear in String s.
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] argv) throws Exception { String s = "java2s.com"; System.out.println(hasCJK(s)); }//from www . j a v a 2 s .c om static Pattern isCJK_pattern = null; /** * Unlike isCJK(s), hasCJK(s) will return true if any CJK characters appear in String s. */ public static Boolean hasCJK(String s) { if (isCJK_pattern == null) isCJK_pattern = Pattern .compile("[\\p{IsHan}\\p{IsHangul}\\p{IsKatakana}\\p{IsHiragana}]"); Matcher m = isCJK_pattern.matcher(s); return m.find(); } }