diff --git a/app/MetaGer.php b/app/MetaGer.php index c8b309558bc443072a96fb33b2e7b4ff5a9c2b23..fdecde0f8827094b37afe81f8c1bc73b32140244 100644 --- a/app/MetaGer.php +++ b/app/MetaGer.php @@ -1213,11 +1213,18 @@ class MetaGer private function searchCheckStopwords($request) { + $oldQ = $this->q; // matches '[... ]-test[ ...]' - while (preg_match("/(^|.*?\s)-(\S+)(\s.*|$)/si", $this->q, $match)) { - $this->stopWords[] = $match[2]; - $this->q = $match[1] . $match[3]; + $words = preg_split("/\s+/si",$this->q); + $newQ = ""; + foreach($words as $word){ + if(strpos($word, "-") === 0 && strlen($word) > 1){ + $this->stopWords[] = substr($word, 1); + }else{ + $newQ .= " " . $word; + } } + $this->q = trim($newQ); # Overwrite Setting if submitted via Parameter if ($request->has('stop')) { $this->stopWords = []; @@ -1231,6 +1238,7 @@ class MetaGer } else { $this->stopWords[] = $stop; } + $this->q = $oldQ; } // print the stopwords as a user warning if (sizeof($this->stopWords) > 0) {