Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Unexpected different behaviour when using parentheses in C# regex
System.Text.RegularExpressions.Regex separatorRegex1
= new System.Text.RegularExpressions.Regex("a");
System.Text.RegularExpressions.Regex separatorRegex2
= new System.Text.RegularExpressions.Regex("(a)");
string str = "a";
string[] split1 = separatorRegex1.Split(str); // { "", "" }
string[] split2 = separatorRegex2.Split(str); // { "", "a", "" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment