From 75682de892f3288d05b708cef0eecc2597c62f20 Mon Sep 17 00:00:00 2001 From: Abir10101 <69311180+Abir10101@users.noreply.github.com> Date: Wed, 26 Oct 2022 16:23:39 +0000 Subject: [PATCH] Fix regex for bolding search terms (#865) Updated regex to not remove chinese letters in bolding regex --- app/utils/results.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/utils/results.py b/app/utils/results.py index 3ab5c2b..2bb522b 100644 --- a/app/utils/results.py +++ b/app/utils/results.py @@ -63,7 +63,7 @@ def bold_search_terms(response: str, query: str) -> BeautifulSoup: if len(element) == len(target_word): return - if not re.match('.*[a-zA-Z0-9].*', target_word) or ( + if re.match('.*[@_!#$%^&*()<>?/\|}{~:].*', target_word) or ( element.parent and element.parent.name == 'style'): return @@ -76,7 +76,7 @@ def bold_search_terms(response: str, query: str) -> BeautifulSoup: # Split all words out of query, grouping the ones wrapped in quotes for word in re.split(r'\s+(?=[^"]*(?:"[^"]*"[^"]*)*$)', query): - word = re.sub(r'[^A-Za-z0-9 ]+', '', word) + word = re.sub(r'[@_!#$%^&*()<>?/\|}{~:]+', '', word) target = response.find_all( text=re.compile(r'' + re.escape(word), re.I)) for nav_str in target: