Re: [問題] 關於string的API
※ 引述《upo (誰說這是個公平的世界)》之銘言:
: 標題: [問題] 關於string的API
: 時間: Fri May 23 12:22:44 2008
: split
: public String[] split(String regex)根據給定正則運算式的匹配拆分此字串。
: 該方法的作用就像是使用給定的運算式和限制引數 0 來呼叫兩引數 split 方法
: 。因此,所得陣列中不套件括結尾空字串。
:
: 另外在 Regex 結果
: : { "boo", "and", "foo" }
: o { "b", "", ":and:f" } ←這裡
:
所以我說... 看 API 還是去看英文版的好... 阿六版的翻譯實在是比英文更難懂 f-.-
Splits this string around matches of the given regular expression.
This method works as if by invoking the two-argument split method with the giv
en expression and a limit argument of zero. Trailing empty strings are therefo
re not included in the resulting array.
boo:and:foo 用 o 來當成 seperator,連續的 o 中間有一個
empty string "", 所以會是
"b", "o", "", "o", ":and:f", "o", "", "o", ""
結果就是 { "b", "", ":and:f", "" }
然後因為 API 裡黃色的那個說明,Trailing empty strings are not included
所以正確的結果會是 { "b", "", ":and:f" }
--
很多人以為 所以我要 其實我是個
我是大學生 告訴大家 三十一歲的怪叔叔
● ●/ ︿ ︿
/勁\ <勁 ●
ㄨ /\ ㄨ
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 147.8.127.102
※ 編輯: superlubu 來自: 147.8.127.102 (05/23 12:45)
推
05/23 12:57, , 1F
05/23 12:57, 1F
推
05/23 13:01, , 2F
05/23 13:01, 2F
推
05/23 13:13, , 3F
05/23 13:13, 3F
推
05/23 14:51, , 4F
05/23 14:51, 4F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 3 篇):