我的代码:
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>';
}));
}
});
Run Code Online (Sandbox Code Playgroud)
我想突出显示带重音的字母,即:
$('body').highlight("cao");
Run Code Online (Sandbox Code Playgroud)
应突出显示:[ção] OR [çÃo] OR [cáo] OR expre [cão] tion或[Cáo] tion
我怎样才能做到这一点?