Trying to make a search script..
Posted: Thu Jun 29, 2006 8:31 pm
My regex is a little wacked. It's isn't staying inside quote pairs. I'm going to regex single words later. I just wanted to get all the phrases out first. Should I split up the string first?
Outputs...
Code: Select all
// create an array of excluded phrases
preg_match_all('#\s*\-".*?"\s*#', $_POST['SearchQuery'], $ExcludedPhrases);
echo '<p><b>Excluded Phrases:</b></p>';
echo '<pre>';
print_r($ExcludedPhrases[0]);
echo '</pre>';
// create an array of included phrases
preg_match_all('#\s*[^-]\+*".*?"\s*#', $_POST['SearchQuery'], $IncludedPhrases);
echo '<p><b>Included Phrases:</b></p>';
echo '<pre>';
print_r($IncludedPhrases[0]);
echo '</pre>';RECEIVED: hi -"don't include me" +findthis -don'tfindthis +"find this phrase"
Excluded Phrases:
Array
(
[0] => -"don't include me"
)
Included Phrases:
Array
(
[0] => e" +findthis -don'tfindthis +"
)