From 59ef9248674c6dcf8d85015c2736467cd4c744cd Mon Sep 17 00:00:00 2001 From: rurban Date: Sun, 11 Sep 2005 14:12:13 +0000 Subject: [PATCH] fix AND WORD pcre asRegexp git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@4818 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/TextSearchQuery.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/TextSearchQuery.php b/lib/TextSearchQuery.php index dd12d6dd2..2d332a786 100644 --- a/lib/TextSearchQuery.php +++ b/lib/TextSearchQuery.php @@ -1,4 +1,4 @@ -word, '/') . ')'; } + function regexp() { return '(?=.*\b' . preg_quote($this->word, '/') . ')'; } function sql() { return $this->_sql_quote($this->word).'%'; } } class TextSearchQuery_node_ends_with extends TextSearchQuery_node_word { var $op = "ENDS_WITH"; - function regexp() { return '(?=' . preg_quote($this->word, '/') . '\b)'; } + function regexp() { return '(?=.*' . preg_quote($this->word, '/') . '\b)'; } function sql() { return '%'.$this->_sql_quote($this->word); } } @@ -348,14 +348,14 @@ extends TextSearchQuery_node_word { class TextSearchQuery_node_regex // posix regex. FIXME! extends TextSearchQuery_node_word { var $op = "REGEX"; // using REGEXP or ~ extension - function regexp() { return '(?=\b' . $this->word . '\b)'; } + function regexp() { return '(?=.*\b' . $this->word . '\b)'; } function sql() { return $this->_sql_quote($this->word); } } class TextSearchQuery_node_regex_glob extends TextSearchQuery_node_regex { var $op = "REGEX_GLOB"; - function regexp() { return '(?=\b' . glob_to_pcre($this->word) . '\b)'; } + function regexp() { return '(?=.*\b' . glob_to_pcre($this->word) . '\b)'; } } class TextSearchQuery_node_regex_pcre // how to handle pcre modifiers? /i @@ -479,6 +479,11 @@ extends TextSearchQuery_node_binop return $this; } + /* FIXME! + * Either we need all combinations of all words to be position independent, + * or we have to use multiple match calls for each AND + * (AND x y) => /(?(:x)(:y))|(?(:y)(:x))/ + */ function regexp() { $regexp = ''; foreach ($this->leaves as $leaf) -- 2.45.0