标签:
示例;
var defaultEmphasisHandler = function(keyword, data){
var regex = RegExp("("+keyword.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1")+")", ‘ig‘);
return data.replace(regex, "<em style=‘color:red;‘>$1</em>");
};
var s=‘我是中国人‘;
document.write(defaultEmphasisHandler(‘我‘,s));
标签:
原文地址:http://www.cnblogs.com/linsu/p/4650682.html