Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Matching a long list of phrases

by artist (Parson)
on Aug 14, 2006 at 16:12 UTC ( [id://567273]=note: print w/replies, xml ) Need Help??


in reply to Matching a long list of phrases

Using very fast Regexp::Trie pointed by fletch
use Regexp::Trie; my $rt = Regexp::Trie->new; open(IN, "phrases.txt"); @list = <IN>; for (@list){ chomp; $rt->add($_); } my $regexp = $rt->regexp; print "$regexp\n"; if ($incoming{text} =~ qr(\b$regexp\b)){ print "Matched: $& \n"; }
--Artist

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://567273]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-24 11:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found