Regex start/end position of match?

Gerald via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Sep 30 20:29:28 PDT 2015


I'm using the std.regex API as part of Linux GUI grep utility I'm 
trying to create. I've got the GUI going fine using gtkd, the 
code to iterate over files (wow that was succinct in D, very 
impressive!), and getting matches via regex using the matchAll 
function.

I'm stuck though on how to get the start/end index of a match? 
Looking at RegexMatch, I don't see an obvious way to get this? 
I'll admit that coming from Java I'm not very comfortable with 
the Range concept in D, however I read the Range and Regex D 
documentation as well as Andrei's article on ranges referenced in 
the docs and I'm still not seeing what I'm missing.

By comparison, the Java API includes the start/end match index in 
the MatchResult interface. I have a feeling I'm not grokking 
something fundamental about Ranges in D, what am I missing?

BTW in case anyone asks, the reason I'm looking for this is to 
highlight the matches when displaying matching lines in the GUI.


More information about the Digitalmars-d-learn mailing list