New regex: Find?

Georg Wrede georg.wrede at iki.fi
Mon May 4 17:27:15 PDT 2009


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?

Your question can be understood in several ways. Others have answered 
one of these. OTOH, if you just have two strings, out of which the 
shorter one is a regex, and you want to know whether it is included in 
the other string, then I suggest using std.string.find which doesn't 
seem to cause heap allocation, and is very fast.




More information about the Digitalmars-d mailing list