From 041cbd97fc9e0b48126ed4dd633fac709599297b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E4=B9=90=E5=A4=A9?= <1249355696@qq.com> Date: Mon, 13 Jun 2022 21:32:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'app/static/js/highlight.j?= =?UTF-8?q?s'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/js/highlight.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/static/js/highlight.js b/app/static/js/highlight.js index d91fb24..21417c1 100644 --- a/app/static/js/highlight.js +++ b/app/static/js/highlight.js @@ -31,7 +31,7 @@ function highLight() { for (var i = 0; i < list.length; ++i) { list[i] = list[i].replace(/(^\s*)|(\s*$)/g, "");//消除字符串两边空字符 if (list[i] != "" && "".indexOf(list[i]) == -1 && "".indexOf(list[i]) == -1) { - + //将正则表达式进行修改 表示搜索的是两端带有空格的list[i] 那么搜索的便为一个完整单词 然后在mark标签的前后各加了一个空格对其进行替换 txt = txt.replace(new RegExp("\\s"+list[i]+"\\s", "g"), " " + list[i] + " "); } } @@ -41,6 +41,7 @@ function highLight() { for (var i = 0; i < list2.length; ++i) { list2[i] = list2[i].replace(/(^\s*)|(\s*$)/g, ""); if (list2[i] != "" && "".indexOf(list2[i]) == -1 && "".indexOf(list2[i]) == -1) { + //将正则表达式进行修改 表示搜索的是两端带有空格的list2[i] 那么搜索的便为一个完整单词 然后在mark标签的前后各加了一个空格对其进行替换 txt = txt.replace(new RegExp("\\s"+list2[i]+"\\s", "g"), " " + list2[i] + " "); } }