From: <ru...@us...> - 2009-10-12 10:41:36
|
Revision: 7203 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7203&view=rev Author: rurban Date: 2009-10-12 10:41:27 +0000 (Mon, 12 Oct 2009) Log Message: ----------- Prioritize search regex "not*" over keyword "not", ditto for "and" and "or". Search for "not*" will now find "*Note" and "*Notes" Modified Paths: -------------- trunk/lib/TextSearchQuery.php Modified: trunk/lib/TextSearchQuery.php =================================================================== --- trunk/lib/TextSearchQuery.php 2009-10-11 14:18:08 UTC (rev 7202) +++ trunk/lib/TextSearchQuery.php 2009-10-12 10:41:27 UTC (rev 7203) @@ -1104,19 +1104,10 @@ $tokens = array(); $buf = $case_exact ? ltrim($string) : strtolower(ltrim($string)); while (!empty($buf)) { - if (preg_match('/^(and|or)\b\s*/i', $buf, $m)) { - $val = strtolower($m[1]); - $type = TSQ_TOK_BINOP; - } - elseif (preg_match('/^(-|not\b)\s*/i', $buf, $m)) { - $val = strtolower($m[1]); - $type = TSQ_TOK_NOT; - } - elseif (preg_match('/^([()])\s*/', $buf, $m)) { + if (preg_match('/^([()])\s*/', $buf, $m)) { $val = $m[1]; $type = $m[1] == '(' ? TSQ_TOK_LPAREN : TSQ_TOK_RPAREN; } - // * => ALL elseif ($regex & (TSQ_REGEX_AUTO|TSQ_REGEX_POSIX|TSQ_REGEX_GLOB) and preg_match('/^\*\s*/', $buf, $m)) { @@ -1166,6 +1157,14 @@ $val = $m[1]; $type = TSQ_TOK_EXACT; } + elseif (preg_match('/^(and|or)\b\s*/i', $buf, $m)) { + $val = strtolower($m[1]); + $type = TSQ_TOK_BINOP; + } + elseif (preg_match('/^(-|not\b)\s*/i', $buf, $m)) { + $val = strtolower($m[1]); + $type = TSQ_TOK_NOT; + } // "words " elseif (preg_match('/^ " ( (?: [^"]+ | "" )* ) " \s*/x', $buf, $m)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |