compile-time regex redux

Robby robby.lansaw at gmail.com
Wed Feb 7 00:11:12 PST 2007


Andrei Alexandrescu (See Website For Email) wrote:
> Walter Bright wrote:
[snipped]
>> The last time I introduced core regular expressions into D, it was 
>> soundly rejected by the community and was withdrawn, and for good 
>> reasons.
>>
>> But I think we now have good reasons to revisit this, at least for 
>> compile time use only. For example:
>>
>>     ("aa|b" ~~ "ababb") would evaluate to "ab"
>>
>> I expect one would generally only see this kind of thing inside 
>> templates, not user code.
> 
> The more traditional way is to mention the string first and pattern 
> second, so:
> 
> ("ababb" ~~ "aa|b") // match this guy against this pattern
> 
> And I think it returns "b" - juxtaposition has a higher priority than 
> "|", so your pattern is "either two a's or one b". :o)
> 
> One program I highly recommend for playing with regexes is The Regex 
> Coach: http://weitz.de/regex-coach/.
> 
> 
> Andrei

I wasn't here during the first round of regexes so bare with me. Though 
I can assume that with D's growing visibility the past few months, I'm 
probably not the only one. Having used Ruby for years I'm quite! fond of 
them, some general questions.

What version of regex would be the target? There's a few variations out 
there.

Probably a couple of green questions, what is the benefit of having a 
compile time regex implementation over a "really fast" implementation? 
Or having the expression compiled and the string allowed runtime?

Assuming ~~ will be the syntax used?

Sidebar chuckle :
http://dev.perl.org/perl6/doc/design/syn/S05.html
Um, wow. They've really turned 5's implementation on its head.. could be 
interesting to watch the reaction from that.. could be louder than the 
vb guys when vb.net was first released..





More information about the Digitalmars-d mailing list