Spaces:
Running
on
L4
Running
on
L4
liamcripwell
commited on
Commit
•
1d15344
1
Parent(s):
8676841
regex lookaheads
Browse files
app.py
CHANGED
@@ -60,8 +60,8 @@ def highlight_words(input_text, json_output):
|
|
60 |
color = color_map[path_key]
|
61 |
# highlighted_text = highlighted_text.replace(f" {value}", f" <span style='background-color: {color};'>{unquote(f'{value}')}</span>")
|
62 |
|
63 |
-
pattern = rf"(
|
64 |
-
replacement = f"
|
65 |
highlighted_text = re.sub(pattern, replacement, highlighted_text, flags=re.IGNORECASE)
|
66 |
|
67 |
return highlighted_text
|
|
|
60 |
color = color_map[path_key]
|
61 |
# highlighted_text = highlighted_text.replace(f" {value}", f" <span style='background-color: {color};'>{unquote(f'{value}')}</span>")
|
62 |
|
63 |
+
pattern = rf"(?<=[ \n\t]){value}(?=[ \n\t\.\,\?\:\;])"
|
64 |
+
replacement = f"<span style='background-color: {color};'>{unquote(value)}</span>"
|
65 |
highlighted_text = re.sub(pattern, replacement, highlighted_text, flags=re.IGNORECASE)
|
66 |
|
67 |
return highlighted_text
|