我在看api帮助文档时看到
 String[] result = "this is a test".split("\\s");
     for (int x=0; x<result.length; x++)
         System.out.println(result[x]);疑问  "\\s"; 是什么意思?
API  是1.5的

解决方案 »

  1.   

    \s代表空格! "\\s"是\s在字符穿中的(转义)表示!
      

  2.   

    \s代表空格! "\\s"是\s在字符穿中的(转义)表示!这些字符你可以在windows的附件字符映射中来查找
      

  3.   

    String[] result = "this is a test".split(" "); 
    String[] result = "this is a test".split("\\s"); 
    他们两个的区别在那?
      

  4.   

    看看这则表达式的知识吧,参考javadoc中的java.util.regex.Pattern说明:
    \s A whitespace character: [ \t\n\x0B\f\r] 
    也就是说除了空格还包括tab换行符等
      

  5.   

    String[] result = "this is a test".split(" ");  
    String[] result = "this is a test".split("\\s");  
    效果一样,只是一个是直接写的空格,一个是通过转义的方式实现的.
      

  6.   

    \s 空白字符:[ \t\n\x0B\f\r] 
    \t 制表符 ('\u0009') 
    \n 新行(换行)符 ('\u000A') 
    \r 回车符 ('\u000D') 
    \f 换页符 ('\u000C')