【发布时间】:2011-05-14 18:54:42
【问题描述】:
我的代码:
jQuery.fn.extend({
highlight: function(search){
var regex = new RegExp('(<[^>]*>)|('+ search.replace(/[.+]i/,"$0") +')','ig');
return this.html(this.html().replace(regex, function(a, b, c){
return (a.charAt(0) == '<') ? a : '<strong class="highlight">' + c + '</strong>';
}));
}
});
我想突出显示带有重音符号的字母, 即:
$('body').highlight("cao");
应该突出显示:[ção] OR [ção] OR [cáo] OR expre[cão]tion OR [Cáo]tion
我该怎么做?
【问题讨论】:
标签: jquery regex unicode highlight diacritics