Regex (?:(?'G')|){n}(?#n > 0) always capture only once in .NET10
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Description
### Description
In .NET10, regex `(?:(?'G')|){n}(?#n > 0)` always capture only once.
### Reproduction Steps
```c#
using System;
using System.Text.RegularExpressions;
var input = "1";
var pattern = @"\w(?:(?'G')|){3}";
{
Console.WriteLine("--------------------interpreter---------------------");
var mh = Regex.Match(input, pattern);
foreach(Capture capture in mh.Groups["G"].Captures)
{
Console.WriteLine($"Index:{capture.Index}, Length:{capture.Length}");
}
}
{
Console.WriteLine("--------------------Compiled---------------------");
var mh = new Regex(pattern, RegexOptions.Compiled).Match(input);
foreach(Capture capture in mh.Groups["G"].Captures)
{
Console.WriteLine($"Index:{capture.Index}, Length:{capture.Length}");
}
}
```
### Expected behavior
```
--------------------interpreter---------------------
Index:1, Length:0
Index:1, Length:0
Index:1, Length:0
--------------------Compiled---------------------
Index:1, Length:0
Index:1, Length:0
Index:1, Length:0
```
### Actual behavior
```
--------------------interpreter---------------------
Index:1, Length:0
--------------------Compiled---------------------
Index:1, Length:0
```
### Regression?
_No response_
### Known Workarounds
_No response_
### Configuration
_No response_
### Other information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.