Java语言高分悬赏:用正则表达式怎么样将一段小说文本中所有的人名全部提取出来呢?
这里的核心就是写一个匹配汉字的正则:
public static void regxChinese(){
// 要匹配的字符串
String source = "<span title='5 星级酒店' class='dx dx5'>";
// 将上面要匹配的字符串转换成小写
// source = source.toLowerCase();
// www.111cn.net 匹配的字符串的正则表达式
String reg_charset = "<span[^>]*?title='([0-9]*[\s|\S]*[u4E00-u9FA5]*)'[\s|\S]
*class='[a-z]*[\s|\S]*[a-z]*[0-9]*'";
Pattern p = Pattern.compile(reg_charset);
Matcher m = p.matcher(source);
while (m.find()) {
System.out.println(m.group(1));
}
}