<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div id="content">
老王张建东老刘账户老王你老张事属于朱新开赵德龙老王始看老王多好玩锁考试
</div>
<button id='btn'>检测</button>
<script>
var con=document.getElementById('content');
var val=con.innerHTML;
var btn=document.getElementById('btn');
var reg=['老王','老刘','老张'];
btn.onclick=filter;
function filter(){
for(var i=0;i<reg.length;i++){
val=val.replace(new RegExp(reg[i],'g'),function($0){return '<font color=red>' + $0 + '</font>'});
con.innerHTML=val;
};
};
</script>
</body>
</html>