DMD 0.148 - regular expressions

Dave Dave_member at pathlink.com
Sun Feb 26 15:51:45 PST 2006


In article <op.s5lhaxyb6b8z09 at ginger.vic.bigpond.net.au>, Derek Parnell says...
>
>On Mon, 27 Feb 2006 04:58:21 +1100, Walter Bright  
><newshound at digitalmars.com> wrote:
>
>>
>> "Lars Ivar Igesund" <larsivar at igesund.net> wrote in message
>> news:dts47r$14c0$1 at digitaldaemon.com...
>>> I liked the idea (match expressions), just not the operator, and I  
>>> thought
>>> that was a common opinion...
>>
>> if ("regex" ~~ "string")
>>     _match. ...
>>
>> The equivalent functionality can now be done with:
>>
>> if (m; search("string", "regex"))
>>     m. ...
>
>I don't think that is quite correct. This program failed to compile ....
>
>   void main()
>   {
>     if (m; search("string", "regex")) {}
>   }
>
>
>I got the messages ...
>   test2.d(3): undefined identifier search
>   test2.d(3): function expected before (), not search of type int
>
>It turns out that "import std.regexp;" is now required.
>
>-- 
>Derek Parnell
>Melbourne, Australia

Maybe a good compromise would be to use a built-in "proxy" for search() and
RegExp (along the same lines as '~~' was originally implemented)? Then there
would be no "perl'ish" syntax, no added operators, no overhead and the same
convenience to doing regex matching.

One problem I see with the new v0.148 regex stuff is that different search
functions (and syntax for them) are used for if() and foreach(), and they aren't
interchangable.

That's going to be confusing for newbies and feels kludgy to me - can't the two
functions be combined somehow?

- Dave





More information about the Digitalmars-d mailing list