Last active
May 19, 2017 17:10
-
-
Save MaxBarraclough/b4878daf17b6fbae91ffcc8e483fb184 to your computer and use it in GitHub Desktop.
Unexpected different behaviour when using parentheses in C# regex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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