-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-System.Text.RegularExpressionsbugdisabled-testThe test is disabled in source code against the issueThe test is disabled in source code against the issuehelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributorsin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Milestone
Description
Regex regex = new("@(a*)+?");
MatchCollection mc = regex.Matches("@");
foreach (Match m in mc)
{
Console.WriteLine($"{m.Index} .. {m.Length + m.Index}");
Console.WriteLine(m.ToString());
}On other regex engines, like PCRE, Nim, Python, Javascript, and Golang you would get 0 .. 1
On .NET Framework this displays 1 .. 1
On .NET 6 it gives
1 .. 3
Unhandled exception. System.ArgumentOutOfRangeException: Index and length must refer to a location within the string. (Parameter 'length')
at System.String.Substring(Int32 startIndex, Int32 length)
at System.Text.RegularExpressions.Capture.get_Value()
at System.Text.RegularExpressions.Capture.ToString()
at Program.<Main>$(String[] args) in C:\Users\danmose\source\repos\ConsoleApp31\ConsoleApp31\Program.cs:line 191
@stephentoub first bug from running Nim tests.
Metadata
Metadata
Assignees
Labels
area-System.Text.RegularExpressionsbugdisabled-testThe test is disabled in source code against the issueThe test is disabled in source code against the issuehelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributorsin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged