Capture offset of matches in std.regex.matchAll?
JD via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jul 8 09:36:15 PDT 2014
On Tuesday, 8 July 2014 at 15:58:47 UTC, Justin Whear wrote:
>
> What do you mean by offset? If you simply mean the index of
> the match,
> as your example seems to indicate, you can zip the matches with
> iota or
> sequence!"n".
>
> If you want the offset in the string where each match begins I
> think
> you're out of luck. I needed something similar a while ago and
> the best
> I could find was using the cumulative length of the pre
> property.
Sorry for my confusing example!
Yes, I was looking for the offset in the string where the matches
begin.
I did some programming in PHP in the past. Their preg_match_all
function has an optional offset_capture flag. I was hoping for
something similar in std.regex...
Good tip, I'll use the cumulative length of pre.
Thanks you both for your replies!
More information about the Digitalmars-d-learn
mailing list