我导师说可以学习prolog试试
[quote=引用 7 楼 ccs02287 的回复:] 正则不好使的话,可以用indexof
正则不好使的话,可以用indexof
[u4E00-u9FA5]汉字?[uFE30-uFFA0]全角字符 [u4E00-u9FA5]汉字?[uFE30-uFFA0]全角字符 public static void regxChinese(){ // 要匹配的字符串 String source = "<span title='5 星级酒店' class='dx dx5'>"; // 将上面要匹配的字符串转换成小写 // source = source.toLowerCase(); // 匹配的字符串的正则表达式 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)); } } public static void regxChinese(){ // 要匹配的字符串 String source = "<span title='5 星级酒店' class='dx dx5'>"; // 将上面要匹配的字符串转换成小写 // source = source.toLowerCase(); // 匹配的字符串的正则表达式 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)); } }
可以匹配的,直接写汉字就行
51,407
社区成员
86,124
社区内容
加载中
试试用AI创作助手写篇文章吧