ctRegex - named submatch

Daniel wyrlon at gmx.net
Tue Aug 7 15:05:35 PDT 2012


On Tuesday, 7 August 2012 at 20:51:28 UTC, Dmitry Olshansky wrote:
>
> Great! I never tried ;) Should just work though...
hehe :)

>
> That all being said experimental tag on ctRegex in DDoc is here 
> for a reason, and that is: ctRegex can't compile nor match full 
> regex testsuite.

Understood, thanks for your quick response nevertheless. :)

There are different errors depending on which of the two captures 
is attempted to be accessed.

auto m = match("a = 42;", 
ctRegex!(`(?P<var>\S+)\s*=\s*(?P<value>\d+);`));
auto c = m.captures;

// c["var"]; =>
core.exception.RangeError at std.regex(2145): Range violation

// c["value"]; =>
Object.Exception at C:\D\dmd2\windows\bin\..\..\src\phobos\std\regex.d(2145): 
no su
bmatch named value



More information about the Digitalmars-d-learn mailing list