Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Searching with MySQL (and REGEXPs)

by gav^ (Curate)
on Apr 02, 2002 at 01:32 UTC ( [id://155901]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    @textquery = ();
    $text =~ s/[^\w\d\s\-]//g;
    ...
        push @textquery, 'search_text LIKE ?';
        push @data, '%' . $word . '%';
    }
    
  2. or download this
    UPDATE table SET search_text = CONCAT_WS(' ', name, headline, caption)
    +;
    
  3. or download this
    $text =~ s/[^\w\d\s'"\-]//g;
    @words = parse_line('\s+', 1, $text);
    
  4. or download this
    unless (@words) {
        @words = split /\s+/, $text;        
    }
    
  5. or download this
    SELECT x, y, z FROM table WHERE x REGEXP '[[:<:]]word[[:>]]'
    
  6. or download this
    SELECT x, y, z FROM table WHERE x LIKE '%word%' AND x REGEXP '[[:<:]]w
    +ord[[:>]]'
    
  7. or download this
    foreach my $word (@words) {
        if ($word =~ s/^(["'])(.+)\1$/$2/) {
    ...
            push @data, '%' . $word . '%';
        }
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-06-21 21:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.