diff --git a/app/static/js/highlight.js b/app/static/js/highlight.js index 9646ff3..368ff94 100644 --- a/app/static/js/highlight.js +++ b/app/static/js/highlight.js @@ -42,8 +42,7 @@ function highLight() { let totalSet = new Set(); for (let i = 0; i < list.length; ++i) { list[i] = list[i].replace(/(^\W*)|(\W*$)/g, ""); // 消除单词两边的非单词字符 - list[i] = list[i].replace('|', ""); - list[i] = list[i].replace('?', ""); + list[i] = list[i].replace(/[!?()]/g, ""); if (list[i] != "" && !totalSet.has(list[i])) { // 返回所有匹配单词的集合, 正则表达式RegExp()中, "\b"匹配一个单词的边界, g 表示全局匹配, i 表示对大小写不敏感。 let matches = new Set(articleContent.match(new RegExp("\\b" + list[i] + "\\b", "gi")));