标签:tool java view pattern out 打印 compile class ==
原文:http://www.open-open.com/code/view/1426332240717
判断字符串中是否含有汉字:
String str = "test中文汉字"; String regEx = "[//u4e00-//u9fa5]"; /** * 判断有没有中文 */ if (str.getBytes().length == str.length()) { System.out.println("无汉字"); } else { System.out.println("有汉字"); } /** * 如果有则打印出来 */ Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str); while (m.find()) { System.out.print(m.group(0) + ""); }
标签:tool java view pattern out 打印 compile class ==
原文地址:http://www.cnblogs.com/shihaiming/p/7194211.html