Strange, regex.split Method matches one null element
- by dontoo
Regex rx = new Regex(@"[+-]");
string[] substrings = rx.Split(expression);
expression = "-9a3dcbh-3bca-4ab4cf-3hc" //This is the iput string
I want to split that string between + or -.
My VS debugger shows substring array like this:
substrings[0] = null //???Why
substrings[1] = 9a3dcbh
substrings[2] = 3bca
substrings[3] = 4ab4cf
substrings[4] = 3hc
Why is the first element of arry null, is it because I am matching +-, and there is no + in my input string?