PhpDig.net

Go Back   PhpDig.net > PhpDig Forums > How-to Forum

Reply
 
Thread Tools
Old 08-25-2005, 08:02 AM   #1
rwillmer
Green Mole
 
Join Date: Aug 2005
Posts: 5
partial/wildcard word searching

I'd like to be able to retrieve all words matching the text I provide e.g. strdup should match pstrdup, apr_pstrdup, etc.

Is this possible with the existing code? or do I need to start hacking the SQL statements?

Rachel
rwillmer is offline   Reply With Quote
Old 08-26-2005, 08:52 PM   #2
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Try editing search_function.php like so:
Code:
$like_start = array( "start" => "%", // is empty
                     "any" => "%", // was a percent
                     "exact" => "%" // is empty
                     );
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 08-27-2005, 03:10 AM   #3
rwillmer
Green Mole
 
Join Date: Aug 2005
Posts: 5
Thanks for that. That seems to get the right search results.

Now, next question, the text tag is showing highlighted results in the search results for those pages where it found an exact match, but not where it found a partial match. For those, I just get the first few lines of the page displayed.

Is there a similar change I need to make for the partial matches to be highlighted too?

Rachel
rwillmer is offline   Reply With Quote
Old 08-27-2005, 09:28 AM   #4
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
In search_function.php find:
Code:
    switch($option) {
        case 'any':
        $reg_strings = "($stop_regs{1}|^)($reg_strings)()";
        break;
        case 'exact':
        $reg_strings = "($stop_regs{1}|^)($reg_strings)($stop_regs{1}|\$)";
        break;
        default:
        $reg_strings = "($stop_regs{1}|^)($reg_strings)()";
    }
And replace with:
Code:
    switch($option) {
        case 'any':
        $reg_strings = "()($reg_strings)()";
        break;
        case 'exact':
        $reg_strings = "($stop_regs{1}|^)($reg_strings)($stop_regs{1}|\$)";
        break;
        default:
        $reg_strings = "()($reg_strings)()";
    }
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 08-27-2005, 09:36 AM   #5
rwillmer
Green Mole
 
Join Date: Aug 2005
Posts: 5
perfect!

thanks for the quick reply...

Rachel
rwillmer is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Only searching from start of word benklocek Troubleshooting 1 03-18-2005 01:14 PM
Indexing "<word>-<word>"? FaberFedor How-to Forum 23 02-28-2005 03:35 AM
Wildcard for banned external links? Slider How-to Forum 5 12-19-2004 08:07 AM
serach more than one word jjpcoca How-to Forum 1 06-19-2004 05:42 AM
What's in a word for 1.8.0? renehaentjens How-to Forum 10 02-18-2004 03:37 AM


All times are GMT -8. The time now is 03:37 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.