yet another regexp engine

Just to tell that there is another regexp engine coming out, re::engine::GNU. that will hopefully show how perl's regexp facility is well done, thanks to its perlreapi.

This library will bring into perl POSIX BRE, Gnu Emacs, AWK regexps etc...

The funny thing is that I took the liberty to exploit what perlreapi says: "Since any scalar can be passed as a pattern, it's possible to implement an engine that does something with an array etc...". The idea is have a default syntax (GNU Emacs), and to use an array or a hash at the right-hand side to specify the syntax of the regular expression string, i.e.:

use re::engine::GNU;
'test' =~ /\(tes\)t/ && print "ok 1\n";
'test' =~ [ 0, '\(tes\)t' ] && print "ok 2\n";
'test' =~ { syntax => 0, pattern => '\(tes\)t' } && print "ok 3\n";

Syntax itself is a bitwised value, with of course predefined constants, e.g.

$re::engine::GNU::RE_SYNTAX_EMACS (default)


Have fun!

Leave a comment

About Jean-Damien Durand

user-pic About::Me::And::Perl