Something in the lines of
(某些东西)
myString.split("\s+");
This groups all white spaces as a delimiter.
(这会将所有空白分组为分隔符。)
So if I have the string:
(因此,如果我有字符串:)
"Hello[space][tab]World"
This should yield the strings "Hello"
and "World"
and omit the empty space between the [space]
and the [tab]
.
(这将产生字符串"Hello"
和"World"
并省略[space]
和[tab]
之间的[space]
。)
As VonC pointed out, the backslash should be escaped, because Java would first try to escape the string to a special character, and send that to be parsed.
(正如VonC指出的那样,应该转义反斜杠,因为Java首先会尝试将字符串转义为特殊字符,然后将其发送给解析。)
What you want, is the literal "\s"
, which means, you need to pass "\\s"
. (您想要的是文字"\s"
,这意味着您需要传递"\\s"
。)
It can get a bit confusing. (可能会造成一些混乱。)
The \\s
is equivalent to [ \\t\\n\\x0B\\f\\r]
(\\s
等效于[ \\t\\n\\x0B\\f\\r]
)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…