84669인 학습
152542인 학습
20005인 학습
5487인 학습
7821인 학습
359900인 학습
3350인 학습
180660인 학습
48569인 학습
18603인 학습
40936인 학습
1549인 학습
1183인 학습
32909인 학습
项目里面用到了分词,但是得到很多无关的分词,比如标点,各种符号之类的。
后来在黑名单里面加了中文停用词,能去除绝大部分,但是还是有一些奇奇怪怪的符号去不掉。
所以求一个正则:只能是 (数字,字母(不区分大小写),汉字)或其任意组合。
比如
谢谢
人生最曼妙的风景,竟是内心的淡定与从容!
\u4E00-\u9FA5\uF900-\uFA2D 加上 \w
public static void main(String[] args) { // TODO implement RegexStuff.main String regex = "([\u4E00-\u9FA5\uF900-\uFA2D]|\\w)+"; //Pattern pattern = Pattern.compile(regex); String str1 = "abcF"; String str2 = "as212"; String str3 = "das你好1d"; String str4 = "34D4H好"; String str5 = "大家"; System.out.println(str1.matches(regex)); // true System.out.println(str2.matches(regex)); // true System.out.println(str3.matches(regex)); // true System.out.println(str4.matches(regex)); // true System.out.println(str5.matches(regex)); // true }
参考http://blog.csdn.net/sww_simpcity/article/details/9082993
\u4E00-\u9FA5\uF900-\uFA2D
加上
\w
参考
http://blog.csdn.net/sww_simpcity/article/details/9082993