Builtin regex (Was: How to complex switch?)

Ary Manzana ary at esperanto.org.ar
Thu May 12 21:14:04 PDT 2011


On 5/12/11 6:42 PM, KennyTM~ wrote:
> On May 12, 11 19:13, Matthew Ong wrote:
>> Hi All,
>>
>> Anyway to include this cool feature of switch with D in the near future?
>
> Why the obsession with 'switch'? 'if' works fine.
>
>>
>> switch(str){
>> // regexp
>> case "abc", "def", "as+b?": s1(); break;
>>
>> case "za+", "wd?", "aaa": s2(); break;
>>
>> default: s3();
>> }
>
> Regex isn't even a built-in feature, why would a 'switch' should support
> it.

How about making regex a built-in feature with this syntax: /regex/ ?

I didn't use regex a lot before I started using Ruby. The thing is, in 
Ruby it's so easy to use regex that I just started using them a lot more 
than before. Of course, ruby has built-in operators for matching regexs, 
so maybe that should also be added to the language (it's the =~ 
operator, but in D it should be a different one.)


More information about the Digitalmars-d mailing list