Regexp::OptimizerRegexp::Optimizer is a Perl module which optimizes regular expressions. | |
Download |
Regexp::Optimizer Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Dan Kogai
- Publisher web site:
- http://search.cpan.org/~oyama/Crypt-Camellia-2.01/lib/Crypt/Camellia.pm
Regexp::Optimizer Tags
Regexp::Optimizer Description
Regexp::Optimizer is a Perl module which optimizes regular expressions. Regexp::Optimizer is a Perl module which optimizes regular expressions.SYNOPSIS use Regexp::Optimizer; my $o = Regexp::Optimizer->new; my $re = $o->optimize(qr/foobar|fooxar|foozap/); # $re is now qr/foo(?:ar|zap)/METHODSThis module is implemented as a subclass of Regexp::List. For methods not listed here, see Regexp::List.$o = Regexp::Optimizer->new; $o->set(key => value, ...)Just the same us Regexp::List except for the attribute below;unexpandWhen set to one, $o->optimize() tries to $o->expand before actually starting the operation. # cases you need to set expand => 1 $o->set(expand => 1)->optimize(qr/ foobar| fooxar| foozar /x);$re = $o->optimize(regexp);Does the job. Note that unlike ->list2re() in Regexp::List, the argument is the regular expression itself. What it basically does is to find groups will alterations and replace it with the result of $o->list2re.$re = $o->list2re(list of words ...)Same as list2re() in Regexp::List in terms of functionality but how it tokenize "atoms" is different since the arguments can be regular expressions, not just strings. Here is a brief example. my @expr = qw/foobar fooba+/; Regexp::List->new->list2re(@expr) eq qr/fooba/; Regexp::Optimizer->new->list2re(@expr) eq qr/foob(?:a+ar)/;Requirements:· Perl Requirements: · Perl
Regexp::Optimizer Related Software