I am trying to iterate each named group in a regular expression (i.e. – (?<name>.*)) and depending on the name of the group set an instance property or add it to a collection. Important part is I will never know the name of the group when using the regular expression so I cannot use the string indexer on my Match. Is there a way to extract the names for my groups within my Match?
I am trying to iterate each named group in a regular expression (i.e. –
Share
You can use
Regex.GroupNameFromNumberto iterate over all the capturing groups in the regex and find their names.