http://qs321.pair.com?node_id=230109


in reply to Perl and MySQL - performing a search...

There is regular expression support in MySQL that allows for queries like this:
sub detect_profanity { my $str = shift; my $sth = $dbh->prepare (qq{ SELECT * FROM `forbidden_usernames` W +HERE `f_user` REGEXP ? }); $sth->execute($str); my $row = $sth->fetchrow_hashref(); $sth->finish(); return "bad" if $row; }
You can also use several special characters/constructs to limit the matches. See the MySQL docs for more info.