日期:2014-05-17 浏览次数:21223 次
public static void main(String[] args) throws Exception {
String str ="jhuywy48r在74yhf47tf6中7dgc782有3y...";
StringBuffer buf = new StringBuffer();
Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
Matcher m = p.matcher(str);
while(m.find()){
String chinese = m.group();//匹配出的中文
String pinyin = "pinyin";//在你的中文与拼音对应中找到对应拼音。
m.appendReplacement(buf, pinyin);
}
m.appendTail(buf);
System.out.println(buf.toString());
}
------解决方案--------------------