Limitation with current regex API

Timon Gehr timon.gehr at gmx.ch
Mon Jan 16 20:04:39 PST 2012


On 01/17/2012 05:00 AM, Nick Sabalausky wrote:
> "Timon Gehr"<timon.gehr at gmx.ch>  wrote in message
> news:jf2p5d$2ria$1 at digitalmars.com...
>> On 01/17/2012 04:03 AM, Nick Sabalausky wrote:
>>> "Vladimir Panteleev"<vladimir at thecybershadow.net>   wrote in message
>>> news:klzeekkilpzwmjmkudhh at dfeed.kimsufi.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)
>>>
>>> That wouldn't work in @safe mode, would it?
>>>
>>>
>>
>> There is nothing unsafe about the operation, so I'd actually expect it to
>> work.
>
> I thought pointer arithmetic was forbidden in @safe?
>
>

I don't know exactly, since @safe is neither fully specified nor 
implemented. In my understanding, in @safe code, operations that may 
lead to memory corruption are forbidden. Pointer - pointer cannot, other 
kinds of pointer arithmetic may.


More information about the Digitalmars-d mailing list