Java examples for Internationalization:Charset
count Chinese Words by regex
//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 text = "java2s.com"; System.out.println(countChineseWords(text)); }/*w w w.j a v a 2s .co m*/ private static final Pattern ChineseCharPatt = Pattern .compile("[\u4e00-\u9fa5]"); public static int countChineseWords(String text) { Matcher m = ChineseCharPatt.matcher(text); int count = 0; while (m.find()) count++; return count; } }