New regex: Find?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon May 4 14:45:35 PDT 2009


Derek Parnell wrote:
> On Mon, 04 May 2009 16:07:58 -0500, Andrei Alexandrescu wrote:
> 
>> Derek Parnell wrote:
>>> On Mon, 04 May 2009 10:09:56 -0500, Andrei Alexandrescu wrote:
>>>
>>>> dsimcha wrote:
>>>>> Is there an *efficient* way to simply test whether a given string contains a
>>>>> given regex in the new std.regex?  Using match() and testing for empty works,
>>>>> but this apparently triggers a bunch of unnecessary heap allocation.  If not,
>>>>> is this a universal enough feature to warrant an enhancement request?
>>>> If you only search once, there will be allocation. However, if you 
>>>> search for the same regex several times there will be no extra 
>>>> allocation so the cost will be amortized.
>>> ranslation: No, there isn't "an *efficient* way".
>>>
>> I think your translation omits important information. I meant exactly 
>> what I said: one isolated search can't be currently helped. Repeated 
>> searches can. This is because one search triggers the construction of a 
>> regex engine, which in turn allocates memory.
> 
> I know you meant exactly what you said. I did understand the concept that
> you were putting forward. However, you didn't actually answer the question.
> Your answer sounds as if it came from a politian. 

I emphatically think not, as my answer was precise and did not try to 
hide anything. Oh, whatever.

Andrei



More information about the Digitalmars-d mailing list