-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Open
Milestone
Description
Description
If name of Named group is a number, and the number is larger than the count of Groups,using Match.Groups to check the groups in quick check in visual studio, u will find wrong infomation of this group. But u can use Match.Groups[number] to accesse this group.
Reproduction Steps
using System;
using System.Text.RegularExpressions;
var pattern = @"(?'2'.)";
//pattern = @"(?'2'.)(?'wtf')";//use this will Output normal result
var input = @"1";
var mh = Regex.Match(input,pattern);
Console.WriteLine(string.Join(",",mh.Groups.Keys)+"#");
Console.WriteLine(mh.Groups[1].Success);
Console.WriteLine(mh.Groups[2].Success);
Console.WriteLine(mh.Groups[2]);
Output:
0,#
False
True
1
Expected behavior
Output:
0,2#
False
True
1
Actual behavior
OUtput:
0,#
False
True
1
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Reactions are currently unavailable