用正则表达进行对每个中文进行匹配而分割
代码如下:
/**
*
*/
package com.tgb.spring.pattern;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author Administrator
*
*/
public class PatternTest {
public static void main(String[] args) {
String s = new String("我是中国人");
System.out.println(checkChinese(s));
}
public static String checkChinese(String str){
String sb = new String();
Pattern pattern = Pattern.compile("[\u3007\u4E00-\u9FCB\uE815-\uE864]");//只匹配一个中文字符
Matcher matcher = pattern.matcher(str);
while(matcher.find()){
sb += matcher.group()+";";
}
return sb.toString();
}
}