我在看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的
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的
String[] result = "this is a test".split("\\s");
他们两个的区别在那?
\s A whitespace character: [ \t\n\x0B\f\r]
也就是说除了空格还包括tab换行符等
String[] result = "this is a test".split("\\s");
效果一样,只是一个是直接写的空格,一个是通过转义的方式实现的.
\t 制表符 ('\u0009')
\n 新行(换行)符 ('\u000A')
\r 回车符 ('\u000D')
\f 换页符 ('\u000C')