Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Perl and MySQL - performing a search...

by trs80 (Priest)
on Jan 27, 2003 at 04:04 UTC ( #230109=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: Perl and MySQL - performing a search...
Download Code
Replies are listed 'Best First'.
Re: Re: Perl and MySQL - performing a search...
by powerhouse (Friar) on Jan 27, 2003 at 05:35 UTC
    EXCELLENT, Thank you, one and all!

    thx,
    Richard

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (16)
As of 2015-07-29 12:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls