日期:2014-05-20  浏览次数:20671 次

中文空格匹配,急
2013-06-17 04:22:10 来源:<http://epaper.xiancn.com/xawb/html/2013-06/17/content_214806.htm> 西安晚报(西安) <#>有0人参与
这段文字里的"(西安)"后的那个中文的空格怎么用正则匹配?

------解决方案--------------------

//注意中间既包含了全角空格,也包含了半角空格
String test =  " 祥/n                   视频/n :/w ";  
String[] subtest =  test.split(" ");    //使用半角空格分隔字符串
  for(String i : subtest){
     if(i != null && !"".equals(i) && !i.matches("[ ]+")){  
  //注意i.matches("[ ]+")中括号中是全角空格,表示匹配任意个全角空格
        System.out.println(i);   
   }