Strange, regex.split Method matches one null element

Posted by dontoo on Stack Overflow See other posts from Stack Overflow or by dontoo
Published on 2010-04-27T18:21:06Z Indexed on 2010/04/27 18:23 UTC
Read the original article Hit count: 419

Filed under:
|
|
|
    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?

© Stack Overflow or respective owner

Related posts about regex

Related posts about .NET