js 实现百度搜索中的高亮显示

highlight: function(value, term) {
  return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong style='color:red'>$1</strong>");
 }

转载于:https://www.cnblogs.com/xffy1028/archive/2012/08/13/2636743.html