Split string with adding separator to substring I wrote my Split() extension, it's main goal is to save delimiters and add them to splitted strings.

For example:
I have a string "-1-2+3+4-5-6", and separators '+', '-'
and I want to have following: "","-1","-2","+3","+4","-5","-6" or "-","1-","2+","3+","4-","5-","6" depends on input separator option.

My extension method consists of three parts:


Check input values;
Getting all indexes of separators, and separators in source string;
Split source string and adding separators to left or right substring.


Code:

public enum SeparatorOptions
{
    None = 0,
    AddSeparatorToLeftSubstring = 1,
    AddSeparatorToRightSubstring = 2
}
public static class Extensions
{
    public static string[] Split(this string source, char[] separators, SeparatorOptions separatorOptions)
    {
        if (separatorOptions &lt; SeparatorOptions.None || separatorOptions &gt; SeparatorOptions.AddSeparatorToRightSubstring)
        {
            throw new ArgumentException("Arg_SeparatorEnumIllegalVal");
        }
        if (separators == null || separators.Length == 0)
        {
            return source.Split((char[])null);
        }
        if (separatorOptions == SeparatorOptions.None)
        {
            return source.Split(separators);
        }
        // Getting all indexes of separators, and separators in source string
        int foundCount = 0;
        int[] separatorIndexes = new int[source.Length];
        char[] separatorValues = new char[source.Length];
        for (int i = 0; i &lt; source.Length; i++)
            for (int j = 0; j &lt; separators.Length; j++)
            {
                char separator = separators[j];
                if (source[i] == separator)
                {
                    separatorValues[foundCount] = source[i];
                    separatorIndexes[foundCount++] = i;
                    break;
                }
            }

        string[] splitString = source.Split(separators);
        // Adding separators to left or right substring
        if (separatorOptions == SeparatorOptions.AddSeparatorToLeftSubstring)
            return AddSeparatorToLeftSubstring(splitString, separatorValues, foundCount);
        if (separatorOptions == SeparatorOptions.AddSeparatorToRightSubstring)
            return AddSeparatorToRightSubstring(splitString, separatorValues, foundCount);
        return splitString;
    }
    private static string[] AddSeparatorToLeftSubstring(string[] splitString, char[] separatorValues, int foundCount)
    {
        for (int i = 0; i &lt; foundCount; i++)
        {
            splitString[i] += separatorValues[i];
        }
        return splitString;
    }
    private static string[] AddSeparatorToRightSubstring(string[] splitString, char[] separatorValues, int foundCount)
    {
        for (int i = 1, j = 0; i &lt;= foundCount; i++, j++)
        {
            splitString[i] = separatorValues[j] + splitString[i];
        }
        return splitString;
    }
}
class Program
{
    static void Main(string[] args)
    {
        string str = "-1-2+3+4-5-6";
        Console.WriteLine("Original split()");
        var res2 = str.Split(new char[] { '+', '-' }, SeparatorOptions.None);
        foreach (var el in res2) Console.WriteLine(el);
        Console.WriteLine("Add to right substring");
        var res = str.Split(new char[] { '+', '-' }, SeparatorOptions.AddSeparatorToRightSubstring);
        foreach (var elem in res) Console.WriteLine(elem);
        Console.WriteLine("Add to left substring");
        var res3 = str.Split(new char[] { '+', '-' }, SeparatorOptions.AddSeparatorToLeftSubstring);
        foreach (var el in res3) Console.WriteLine(el);
        Console.ReadKey();
    }
}


What I wrote seems to work, although I am not sure if it is the best way, or recommended way to do something like this, so I want to ask what is wrong with my code and how could it be done better.
Review

You use very clean and strong names for all your variables so it's very easy to understand your code.
You too often go without {}. Especially the double for loops become very confusing.
You don't use good exception messages. In Arg_SeparatorEnumIllegalVal the Arg prefix is not necessary because the type of the exctpion is already telling me it's about an argument. You also formatted it like it was a variable with PascalCase but it's a message so it should be formatted like a normal sentence.

Alternative solution
There is a much shorter way to get the same results. You could use two different regexes:
var str = &quot;-1-2+3+4-5-6&quot;;

Regex.Matches(str, &quot;([-+]?[0-9]?)&quot;).Cast&lt;Match&gt;().Select(m =&gt; m.Value).Dump();
Regex.Matches(str, &quot;([0-9]?[-+]?)&quot;).Cast&lt;Match&gt;().Select(m =&gt; m.Value).Dump();

which will respectively give you:
-1 
-2 
+3 
+4 
-5 
-6 
&quot;&quot;

and
- 
1- 
2+ 
3+ 
4- 
5- 
6 
&quot;&quot; 

Whether you want to keep the empty string or not is up to you.