Subject: | Regexp::Assemble and possessive quantifiers |
Dear David,
I have noticed a major shortcoming and incompatibility in the
Regexp::Assemble package. It seems that it does not handle possessive
quantifiers correctly. This is especially problematic since both
possessive quantifiers and regexp optimization are used for performace
reasons, and therefore these techniques would commonly be used together.
Regexp::Assemble considers the latter plus as a literal character, and
for example the regexp "x++" is converted into "x+\+".
While the case above can be simply converted back, it gets much more
complicated if the plus is noticed as a common portion, for example from
"foo++", "bar++" into "(foo+|bar+)\+".
Does Regexp::Assemble contain any support for possessive quantifiers, or
do you have any other suggestions how to work around the problem?
Below is a test script that assembles and prints out a regexp using
possessive quantifiers. I'm obliged for any help you can offer.
Best regards,
Sampo N.
#!/usr/bin/perl
use Regexp::Assemble;
my $ra = Regexp::Assemble->new;
$ra->add("x++");
print $ra->as_string() . "\n";