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

Daniel Keep daniel.keep.lists at gmail.com
Thu Feb 19 00:14:30 PST 2009



BCS wrote:
> Hello Bill,
> 
>> What about turning it around and using 'in' though?
>>
>> foreach(e; regex("a[b-e]", "g") in "abracazoo")
>> writeln(e);
> 
> vote += lots; // I had the same thought as well

If a regex represents a set of strings, then wouldn't

  "abracazoo" in regex("a[b-e]", "g")

make more sense?  Of course, that's "match" semantics; if you turn it
around and say that you're looking for elements from the set in the
string, then it's

  regex("a[b-e]", "g") in "abracazoo"

Hmm...

None the less, I do prefer the 'in' syntax over the '~' syntax.  Please
let's no go down the road of co-opting operators to do things other than
what they're designed for.

If you REALLY want a custom operator, you could always convince Walter
to let us define infix functions using Unicode characters.  :D

  -- Daniel



More information about the Digitalmars-d mailing list