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

---

Example code:

import std.stdio;
import std.regex;

void main()
{
        auto input = "<html><body><p>{{ message }}</p></body></html>";
        
        auto ctr = ctRegex!(`(\{\{|\{\%|\{\#)?`, "s");

        auto matches = matchAll(input, ctr);

          /*
        auto offset = 0;
        foreach(match;matches)
        {
                writeln(offset, ":", match);
                ++offset;
        }
         */
}

Reply via email to