From b733893d924012d8246b6d6174197b5f14b446b9 Mon Sep 17 00:00:00 2001 From: Bofh Date: Sun, 11 Dec 2022 19:32:50 +0100 Subject: [PATCH] normalize_for_search on words matched in the search --- base.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/base.php b/base.php index 71b85de..da9e926 100644 --- a/base.php +++ b/base.php @@ -384,6 +384,7 @@ function matches_comparing_expression($expr, $text) { if (gettype($expr) === 'string') $expr = parse_comparing_expression($expr); $result = $expr['original']; + $text_words = explode(' ', $text); foreach ($expr['parsed'] as $lvl => $exl) { foreach ($exl as &$t) { if (strpos($t, 'words ') === 0) { @@ -391,7 +392,7 @@ function matches_comparing_expression($expr, $text) { $ws = explode(' ', trim(trim($w, '"'))); $haveall = true; foreach ($ws as $w) { - if (strpos($text, $w) === false) { + if (!in_array(normalize_for_search($w), $text_words)) { $haveall = false; break; } @@ -400,7 +401,7 @@ function matches_comparing_expression($expr, $text) { } else if (strpos($t, 'contains ') === 0) { $w = substr($t, strlen('contains')+1); $w = trim(trim($w, '"')); - $contains = strpos($text, $w) !== false; + $contains = strpos($text, normalize_for_search($w)) !== false; $result = str_replace($t, $contains ? 'true' : 'false', $result); } }