[Issue 16446] New: Captures does not expose named captures for iteration
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Aug 29 16:41:36 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=16446
Issue ID: 16446
Summary: Captures does not expose named captures for iteration
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: justin at economicmodeling.com
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);
--
More information about the Digitalmars-d-bugs
mailing list