17 buffer =
new string[bufferSize];
39 public int Split(
string value,
char separator)
45 for (
int i = 0; i < value.Length; i++)
47 if (value[i] == separator)
49 buffer[resultIndex] = value.Substring(startIndex, i - startIndex);
56 buffer[resultIndex] = value.Substring(startIndex, value.Length - startIndex);
77 for (
int i = 0; i < value.Length; i++)
79 if (value[i] == separator)
82 if (
buffer.Length == resultIndex)
87 buffer[resultIndex] = value.Substring(startIndex, i - startIndex);
94 if (
buffer.Length == resultIndex)
100 buffer[resultIndex] = value.Substring(startIndex, value.Length - startIndex);
102 return resultIndex + 1;
112 public int Split(
string value,
string separator)
119 int maxIndex = value.Length - separator.Length;
120 for (
int i = 0; i < maxIndex; i++)
122 bool matchFound =
true;
123 for (
int n = 0; n < separator.Length && (n + i) < value.Length; n++)
125 if (value[i + n] != separator[n])
134 buffer[resultIndex] = value.Substring(startIndex, i + separator.Length - startIndex - separator.Length);
136 startIndex = i + separator.Length;
137 i += separator.Length - 1;
141 buffer[resultIndex] = value.Substring(startIndex, value.Length - startIndex);
142 return resultIndex + 1;
157 int maxIndex = value.Length - separator.Length;
158 for (
int i = 0; i < maxIndex; i++)
161 bool matchFound =
true;
162 for (
int n = 0; n < separator.Length && (n + i) < value.Length; n++)
164 if (value[i + n] != separator[n])
174 if (
buffer.Length == resultIndex)
179 buffer[resultIndex] = value.Substring(startIndex, i + separator.Length - startIndex - separator.Length);
181 startIndex = i + separator.Length;
182 i += separator.Length - 1;
187 if (
buffer.Length == resultIndex)
192 buffer[resultIndex] = value.Substring(startIndex, value.Length - startIndex);
193 return resultIndex + 1;
205 public int Split(
string value,
char[] separators)
211 for (
int i = 0; i < value.Length; i++)
214 bool matchFound =
false;
215 for (
int n = 0; n < separators.Length; n++)
217 if (value[i] == separators[n])
226 buffer[resultIndex] = value.Substring(startIndex, i - startIndex);
233 buffer[resultIndex] = value.Substring(startIndex, value.Length - startIndex);
254 for (
int i = 0; i < value.Length; i++)
257 bool matchFound =
false;
258 for (
int n = 0; n < separators.Length; n++)
260 if (value[i] == separators[n])
270 if (
buffer.Length == resultIndex)
275 buffer[resultIndex] = value.Substring(startIndex, i - startIndex);
282 if (
buffer.Length == resultIndex)
288 buffer[resultIndex] = value.Substring(startIndex, value.Length - startIndex);
304 public int Split(
string value,
char separator, StringSplitOptions options)
310 for (
int i = 0; i < value.Length; i++)
312 if (value[i] == separator)
314 if (options == StringSplitOptions.None || i - startIndex > 0)
316 buffer[resultIndex] = value.Substring(startIndex, i - startIndex);
325 if (options == StringSplitOptions.None || value.Length - startIndex > 0)
327 buffer[resultIndex] = value.Substring(startIndex, value.Length - startIndex);
344 public int SafeSplit(
string value,
char separator, StringSplitOptions options)
350 for (
int i = 0; i < value.Length; i++)
352 if (value[i] == separator)
354 if (options == StringSplitOptions.None || i - startIndex > 0)
357 if (
buffer.Length == resultIndex)
361 buffer[resultIndex] = value.Substring(startIndex, i - startIndex);
370 if (options == StringSplitOptions.None || value.Length - startIndex > 0)
373 if (
buffer.Length == resultIndex)
378 buffer[resultIndex] = value.Substring(startIndex, value.Length - startIndex);
393 public int Split(
string value,
string separator, StringSplitOptions options)
400 int maxIndex = value.Length - separator.Length;
401 for (
int i = 0; i < maxIndex; i++)
403 bool matchFound =
true;
404 for (
int n = 0; n < separator.Length && (n + i) < value.Length; n++)
406 if (value[i + n] != separator[n])
415 if (options == StringSplitOptions.None || i + separator.Length - startIndex - separator.Length > 0)
417 buffer[resultIndex] = value.Substring(startIndex, i + separator.Length - startIndex - separator.Length);
421 startIndex = i + separator.Length;
422 i += separator.Length - 1;
426 if (options == StringSplitOptions.None || value.Length - startIndex > 0)
429 buffer[resultIndex] = value.Substring(startIndex, value.Length - startIndex);
443 public int SafeSplit(
string value,
string separator, StringSplitOptions options)
449 int maxIndex = value.Length - separator.Length;
450 for (
int i = 0; i < maxIndex; i++)
453 bool matchFound =
true;
454 for (
int n = 0; n < separator.Length && (n + i) < value.Length; n++)
456 if (value[i + n] != separator[n])
465 if (options == StringSplitOptions.None || i + separator.Length - startIndex - separator.Length > 0)
468 if (
buffer.Length == resultIndex)
472 buffer[resultIndex] = value.Substring(startIndex, i + separator.Length - startIndex - separator.Length);
476 startIndex = i + separator.Length;
477 i += separator.Length - 1;
481 if (options == StringSplitOptions.None || value.Length - startIndex > 0)
484 if (
buffer.Length == resultIndex)
490 buffer[resultIndex] = value.Substring(startIndex, value.Length - startIndex);
507 public int Split(
string value,
char[] separators, StringSplitOptions options)
513 for (
int i = 0; i < value.Length; i++)
516 bool matchFound =
false;
517 for (
int n = 0; n < separators.Length; n++)
519 if (value[i] == separators[n])
528 if (options == StringSplitOptions.None || i - startIndex > 0)
530 buffer[resultIndex] = value.Substring(startIndex, i - startIndex);
539 if (options == StringSplitOptions.None || value.Length - startIndex > 0)
542 buffer[resultIndex] = value.Substring(startIndex, value.Length - startIndex);
559 public int SafeSplit(
string value,
char[] separators, StringSplitOptions options)
565 for (
int i = 0; i < value.Length; i++)
568 bool matchFound =
false;
569 for (
int n = 0; n < separators.Length; n++)
571 if (value[i] == separators[n])
580 if (options == StringSplitOptions.None || i - startIndex > 0)
583 if (
buffer.Length == resultIndex)
588 buffer[resultIndex] = value.Substring(startIndex, i - startIndex);
597 if (options == StringSplitOptions.None || value.Length - startIndex > 0)
600 if (
buffer.Length == resultIndex)
606 buffer[resultIndex] = value.Substring(startIndex, value.Length - startIndex);
A high performance string splitter https://github.com/meikeric/String.Split/blob/master/Split....
int SafeSplit(string value, char separator)
Returns a string array that contains the substrings in this instance that are delimited by elements o...
int SafeSplit(string value, char separator, StringSplitOptions options)
Returns a string array that contains the substrings in this instance that are delimited by elements o...
string[] buffer
The string buffer container.
int Split(string value, string separator, StringSplitOptions options)
Returns a string array that contains the substrings in this instance that are delimited by a specifie...
StringSplitter(int bufferSize)
Create a new StringSplitter object with the given buffer size.
int SafeSplit(string value, string separator)
Split the string.
int SafeSplit(string value, char[] separators, StringSplitOptions options)
Returns a string array that contains the substrings in this instance that are delimited by elements o...
int SafeSplit(string value, string separator, StringSplitOptions options)
Split the string.
int Split(string value, char separator, StringSplitOptions options)
Returns a string array that contains the substrings in this instance that are delimited by elements o...
int Split(string value, char separator)
Returns a string array that contains the substrings in this instance that are delimited by elements o...
int Split(string value, char[] separators)
Returns a string array that contains the substrings in this instance that are delimited by elements o...
int SafeSplit(string value, char[] separators)
Returns a string array that contains the substrings in this instance that are delimited by elements o...
int Split(string value, string separator)
Returns a string array that contains the substrings in this instance that are delimited by a specifie...
int Split(string value, char[] separators, StringSplitOptions options)
Returns a string array that contains the substrings in this instance that are delimited by elements o...
string[] Results
Get the results of the last split call.