Is str ~ regex the root of all evil, or the leaf of all good?

Sergey Gromov snake.scaly at gmail.com
Fri Feb 20 04:59:50 PST 2009


Thu, 19 Feb 2009 07:46:47 -0800, Andrei Alexandrescu wrote:

> The argument could go both ways:
> 
> "Organize the set of 2-char strings starting with 'c' and ending with 
> 'a' to 'z' into a structured haystack, then look for substrings of 
> "conoco" in that haystack."
> 
> versus
> 
> "Given the unstructured haystack conoco, look for a structured needle in 
> it that is any 2-char string starting with 'c' and ending with 'a' to 'z'."
> 
> What is the most natural way?

I think calling a regex a 'haystack' is a far-fetched metaphor.  A
haystack is a pile of stuff, and a needle is a precise thing you're
looking for.  I think they're unambiguous.

Also, the in operator doesn't leave you guessing whether you should put
a haystack or a needle first.



More information about the Digitalmars-d mailing list