I would like to split a string into a String[] using a String as a delimiter.
String delimit = "[break]";
String[] tokens = myString.Split(delimit);
But the method above only works with a char as a delimiter.
Any takers?
I would like to split a string into a String[] using a String as a delimiter.
String delimit = "[break]";
String[] tokens = myString.Split(delimit);
But the method above only works with a char as a delimiter.
Any takers?
Like this:
mystring.Split(new string[] { delimit }, StringSplitOptions.None);
For some reason, the only overloads of Split
that take a string take it as an array, along with a StringSplitOptions
.
I have no idea why there isn't a string.Split(string)
overload.
I personally prefer to use something like this, since regex has that split:
public static string[] Split(this string input, string delimit)
{
return Regex.Split(input, delimit);
}