www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Regex multiple matches

reply Jethro <qyzz gr.ff> writes:
using the rule (?P<name>regex)

e.g., (?P<names>\w*)*

how do we get at all the matches, e.g., Joe Bob Buddy?

When I access the results captures they are are not arrays and I 
only ever get the first match even when I'm using matchAll.
Apr 13 2017
parent rikki cattermole <rikki cattermole.co.nz> writes:
On 14/04/2017 3:54 AM, Jethro wrote:
 using the rule (?P<name>regex)

 e.g., (?P<names>\w*)*

 how do we get at all the matches, e.g., Joe Bob Buddy?

 When I access the results captures they are are not arrays and I only
 ever get the first match even when I'm using matchAll.
Pseudo code: foreach(result; matcher) { ... } It returns an input range that can "act" as an array without the lookup by index, it is a very powerful abstraction.
Apr 13 2017