Limitation with current regex API

Jerry jlquinn at optonline.net
Mon Jan 16 21:40:27 PST 2012


Mail Mantis <mail.mantis.88 at gmail.com> writes:

> 2012/1/17 Vladimir Panteleev <vladimir at thecybershadow.net>:
>> On Tuesday, 17 January 2012 at 01:44:37 UTC, Vladimir Panteleev wrote:
>>>
>>> On Monday, 16 January 2012 at 19:28:42 UTC, Jerry wrote:
>>>>
>>>> As far as I can tell, the only way to do this would be to capture every
>>>> chunk of text, then iterate to determine the offsets.
>>>
>>>
>>> Not sure if this is what you were referring to, but you can do...
>>
>>
>> Even simpler: m.captures[1].ptr - s.ptr
>>
>> (s is the string being matched)
>
> Correct me if I'm wrong, but wouldn't this be better:
> (m_captures[1].ptr - s.ptr) / s[0].sizeof;

I *think* pointer arithmetic handles that.  However this is much uglier
than:

m_captures[1].begin
m_captures[1].end

Jerry


More information about the Digitalmars-d mailing list