
perlkid
stranger
May 4, 2000, 12:16 PM
Post #1 of 6
(443 views)
|
|
pattern matching
|
Can't Post
|
|
Hello everyone, I'm trying to get a search engine to match whole words but not the whole field. I want the engine to pick up jaguar when the field says jaguar cars, or jaguar parts, and just jaguar of course but this line of code picks up pieces of the words in the field that it's trying to compare the search word with. ex. you type in seat, but the results are for seattle. I go into the script and have it do exact matching. type in seat, I get seat results. type in jaguar I get jaguar results but it doesn't pick up the fields that say jaguar cars, or jaguar parts. when I had it do exact matching I used; $srchwrdlc = lc($in{'srchwrd'}); if ($wholestring eq "$srchwrdlc") { push (@results,$line); } then when it was picking up seat in seattle the code was ($one1, $two2, $three3, $four4, $five5, $six6, $seven7)=split(/ /, $words); if ($wholestring =~/\b$one1/ && $wholestring =~/\b$two2/ && $wholestring =~/\b$three3/ && $wholestring =~/\b$four4/ && $wholestring =~/\b$five5/ && $wholestring=~/\b$six6/ && $wholestring =~/\b$seven7/){ push (@results,$line);} $wholestring is the field I'm trying to match the searched word with, $words is the search word. How can I get the engine to pick up jaguar car results and jaguar results when you type in jaguar but get seat resutls when I type in seat, not seattle results. Whole word matching but no whole field? Thanks a lot, perlkid
|