Finding the intersection between two regexes
James Laver
james.laver at gmail.com
Mon Apr 21 10:03:22 BST 2014
On 21 Apr 2014, at 09:45, Dirk Koopman <djk at tobit.co.uk> wrote:
> This may be related to the question I asked recently about turning (up to) a few hundred REGEXes into one giant REGEX. The goal being to test all those disparate REGEXes in the most efficient way possible on a string.
Sounds like an implementation detail.
My reading of the problem was this:
package Evil;
use Moose;
has regexen => (
is => ‘ro’,
default => sub { [] },
traits => [‘Array’],
handles => {
add_regex => ‘push’,
res => ‘elements’,
},
);
sub go {
my ($self, $datum) = @_;
for my $r ($self->res) {
return 0 if $datum !~ $r;
}
1;
}
__PACKAGE__->meta->make_immutable;
1;
__END__
More information about the london.pm
mailing list