regex issue
Dmitry Olshansky
dmitry.olsh at gmail.com
Mon Mar 19 06:20:37 PDT 2012
On 19.03.2012 16:59, Jay Norwood wrote:
> On Monday, 19 March 2012 at 08:14:18 UTC, Dmitry Olshansky wrote:
>> On 19.03.2012 12:05, Dmitry Olshansky wrote:
>>>
>>> In that case, I should have been able to do something like:
>>>>
>>>> matches=match(input,ctr);
>>>> l_cnt = matches.length();
>>
>> I'm curious what this length() does as I have no length for RegexMatch
>> in the API :)
>>
>>>>
>>>> But I only get length=1, and so I'm a bit concerned that greedy is not
>>>> really working. In fact, it is about 3x faster to just run the second
>>>> piece of code, so I think something must be wrong...
>
> http://dlang.org/phobos/std_regex.html#length
>
> Yes, I should have typed matches.captures.length. It is always returning
> 1, even though the desciption indicates the "g" flag should create a
> match object that contains all the submatches.
>
Captures is a range of submatches as in "(a)(b)(c)" has 3 sub matches +
1 whole match == 4.
--
Dmitry Olshansky
More information about the Digitalmars-d-learn
mailing list