0

请为我提供正则表达式以在页面中仅突出显示一次单词。我现在正在使用这个:

highlightRegex = new RegExp("" + highlightWordsConcat + "(?!')", "ig"); 

我不想显示页面上已经突出显示的单词。

问候。

4

1 回答 1

0

问题很模糊,但可能你正在寻找这样的东西:

s = 'provide me regex to highlight word only once in a page, using regex only'
var r = s.replace(/(regex)/i, '<b>$1</b>');

console.log(r);

输出:

“提供正则表达式在页面中仅突出显示单词一次,仅使用正则表达式”

于 2013-10-28T11:35:30.170 回答