What if I want to split a string using a delimiter that is a word?
For example, This is a sentence
.
I want to split on is
and get This
and a sentence
.
In Java
, I can send in a string as a delimiter, but how do I accomplish this in C#
?
http://msdn.microsoft.com/en-us/library/system.string.split.aspx
Example from the docs:
string source = "[stop]ONE[stop][stop]TWO[stop][stop][stop]THREE[stop][stop]";
string[] stringSeparators = new string[] {"[stop]"};
string[] result;
// ...
result = source.Split(stringSeparators, StringSplitOptions.None);
foreach (string s in result)
{
Console.Write("'{0}' ", String.IsNullOrEmpty(s) ? "<>" : s);
}