将问号替换为空字符串,用来达到过滤问号的作用 #71

Open
XuLingLing wants to merge 1 commits from Bug492-XuHongJian into master
1 changed files with 1 additions and 0 deletions

View File

@ -29,6 +29,7 @@ function highLight() {
const list = allWords.split(" ");
for (let i = 0; i < list.length; ++i) {
list[i] = list[i].replace(/(^\s*)|(\s*$)/g, ""); //消除单词两边的空字符
list[i] = list[i[.replace('?', ""); //消除问号
if (list[i] !== "" && "<mark>".indexOf(list[i]) === -1 && "</mark>".indexOf(list[i]) === -1) {
//将文章中所有出现该单词word的地方改为" <mark>" + word + "<mark> "。 正则表达式RegExp()中,"\\s"代表单词前后必须要有空格,以防止只对单词中的部分字符高亮的情况出现。
articleContent = articleContent.replace(new RegExp("\\s"+list[i]+"\\s", "g"), " <mark>" + list[i] + "</mark> ");