単語検索で空白文字を含むフレーズ検索を可能にします。
' または " で括られた文字列はフレーズとして扱うようになります。
--- func.org.php Sun Feb 20 12:50:06 2005 +++ func.php Sat Jul 16 12:38:34 2005 @@ -171,6 +171,13 @@ return $retval; } +function split_search_word($word) +{ + $matches = array(); + preg_match_all('/((["\'])(?:(?!\2).)+\2|[^\s]+)/', $word, $matches); + return preg_replace('/^(["\'])(.+)\1$/', '$2', $matches[1]); +} + // 'Search' main function function do_search($word, $type = 'AND', $non_format = FALSE) { @@ -181,7 +188,7 @@ $retval = array(); $b_type = ($type == 'AND'); // AND:TRUE OR:FALSE - $keys = get_search_words(preg_split('/\s+/', $word, -1, PREG_SPLIT_NO_EMPTY)); + $keys = get_search_words(split_search_word($word)); $_pages = get_existpages(); $pages = array();
--- html.org.php Wed Jan 26 13:26:38 2005 +++ html.php Sat Jul 16 12:37:00 2005 @@ -113,9 +113,7 @@ if ($search_word_color && isset($vars['word'])) { $body = '<div class="small">' . $_msg_word . htmlspecialchars($vars['word']) . '</div>' . $hr . "\n" . $body; - $words = array_flip(array_splice( - preg_split('/\s+/', $vars['word'], -1, PREG_SPLIT_NO_EMPTY), - 0, 10)); + $words = array_flip(array_splice(split_search_word($vars['word']), 0, 10)); $keys = array(); foreach ($words as $word=>$id) $keys[$word] = strlen($word); arsort($keys, SORT_NUMERIC);