3 ms·
And the regex engine is amazingly fast (there is one faster I believe). Try throwing a 20,000 item list at this little program, and then use the resulting rege
by singingfish 14y ago
And the regex engine is amazingly fast (there is one faster I believe). Try throwing a 20,000 item list at this little program, and then use the resulting regex to match another 20,000 items and see how long it runs (hint: not very, considering):
#!/usr/bin/env perl
use warnings;
use strict;
use Regexp::Assemble;
my $ra = Regexp::Assemble->new;
while (<>) {
chomp;
$ra->add($_);
}
print $ra->re . "\n";
- singingfish 14y agoWell I'm told that newer versions of perl optimise alternations internally and this is redundant now: my $re = join "|", @list; my (@matches) = $txt =~ /$re/g; Quicker and faster...