Capture offset of matches in std.regex.matchAll?

JR via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 8 07:04:31 PDT 2014


On Monday, 7 July 2014 at 21:32:30 UTC, JD wrote:
> I'm using a compile time regex to find some tags in an input
> string. Is it possible to capture the offset of the matches in
> some way? Otherwise I have to "calculate" the offsets myself by
> iterating over the results of matchAll.
>
> Thanks,
> Jeroen

I believe what matchAll returns evaluates its .front lazily, so 
aye; you need to pop it until you get to the match you want. :< 
(assuming I understand the question correctly)

You can however index the *captured fields* in a specific match. 
I couldn't wrap my head around your example pattern but see 
http://dpaste.dzfl.pl/f693db93c3a4 for a dumbed-down version.

You can't slice match, nor can you have foreach provide an index 
variable. This may be to have foreach include named fields? Not 
sure.


More information about the Digitalmars-d-learn mailing list