2010-10-07 83 views

回答

20

它確實。閱讀here

string source = "[stop]ONE[stop][stop]TWO[stop][stop][stop]THREE[stop][stop]"; 
string[] stringSeparators = new string[] {"[stop]"}; 

// Split a string delimited by another string and return all elements. 
string[] result = source.Split(stringSeparators, StringSplitOptions.None); 

編輯: 或者,你可以有一些更復雜的選擇(正則表達式)。這裏,http://dotnetperls.com/string-split

5

String.Split做你想做的。使用接受字符串數組的重載。

實施例:

string[] result = "Asaf_ER_Army".Split(
    new string[] {"ER"}, 
    StringSplitOptions.None); 

結果:

 
Asaf_ 
_Army