列子一:
class teststringsplit輸出; string text = "one/ttwo three:four,five six seven";
system.console.writeline("original text: ''", text);
string words = text.split(delimiterchars);
system.console.writeline(" words in text:", words.length);
foreach (string s in words)
}}
original text: 'one two three:four,five six seven'例子二:7 words in text:
onetwo
three
four
five
sixseven
char delimit = new此**將在單獨的行上輸出每個單詞,如下所示:char ;
string s10 = "the cat sat on the mat.";
foreach (string substr in s10.split(delimit))
the
cat
sat on
the
mat.
split(字串方法)
用於把乙個字串分割成字串陣列。返回值 乙個字串陣列,不包括 sep 自身 引數 string.split sep,many sep必需。字串或正規表示式,從該引數指定的地方分割 stringobject。many 可選。該引數可指定返回的陣列的最大長度。如果設定了該引數,返回的子串不會多於這個引數指...
split方法拆分字串
使用split 時應注意檢查最後乙個分隔符後面有無內容,否則最終分割出的陣列元素個數有可能與預期得到的個數不相符,導致異常!string str 1,2,string list1 str.split string list2 str.split 1 string list3 stringutils....
split分割字串
string tmp weekcode.split new char string yr tmp 0 string wk tmp 1 string tmp regex.split eachl,error regexoptions.ignorecase 用字串來分割 error 把 以 error 為...