The Captures struct maintains an internal list of named subexpressions in _names but it is private and the public API offers no way to discover which named subexpressions exist, only indexing when the subexpression's name is already known. Ideal usage scenario would look like this:
string sample = "ABCDEFG";
auto re = regex( getExpressionFromuser() );
auto captures = sample.matchFirst(re);
foreach (string name, string hit; captures.namedSubExpressions)
writeln(name, ": ", hit);
Comment #1 by robert.schadek — 2024-12-01T16:27:45Z