Q:

Regex - Why are the named groups located at the end of the group array?

Why are the named groups located at the end of the group array?
Pattern for example (with named and unnamed groups):
(?<digit>\d+)\|(?<main>\d+)\|(\d+)\|(?<abc>\d+)\|(\d+)

And text:
123|456|789|10|11

Why "789" and "11" located at the beginning of array?

See demo systemtextregularexpressions.com
Sorry for my english :)

A:

Well... it's simply an implementation choice made in the .NET Framework.
The documentation explains the algorithm:

Both unnamed and named capturing groups can be accessed by number. Unnamed groups are numbered from left to right starting with 1. (The capturing group in index 0 (zero) represents the match as a whole.) Named groups are then numbered from left to right starting with a number that is one greater than the number of unnamed capturing groups.

The same does not necessarily apply for other flavors, for instance PCRE assigns group numbers in the order they appear in the pattern whether they're named or not.

