Let's stop parser Hell

Philippe Sigaud philippe.sigaud at gmail.com
Mon Aug 6 11:52:25 PDT 2012


> I cut my teeth on perl, so everything gets compared to perl in my mind.
>
> In perl, I can 'precompile' a regular expression, so I can avoid some
> overhead. So something like this:
>
> while(<STDIN>){
>     if($_ =~ m/<someregex>/){
>         some work;
>     }
> }
>
> Would end up re-compiling the regex on each line from STDIN. Perl uses the
> term "compiling" the regular expression, which may be different than what
> you call "setup regex engine".
>
> Does/Can D's std.regex offer something like this? If not, I would be
> interested in why not.

D does have compiled regex, it's called ctRegex (meaning compile-time regex):

http://dlang.org/phobos/std_regex.html#ctRegex

The tests done recently put it among the fastest regex engine known.
Caution: not every regex extension known to mankind is implemented
here!


More information about the Digitalmars-d mailing list