<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<p>
<textarea name="" id="area" cols="30" rows="10"></textarea>
</p>
<p>
<input type="submit" value="发布" id="input" />
</p>
<p id="res"></p>
<script>
let area = document.getElementById('area');
let input = document.getElementById('input');
let res = document.getElementById('res');
// 正则表达式。/g是全局
let reg = /川普|你妈的/g;
input.onclick = function(){
let newarea = area.value.replace(reg,'*');
console.log(newarea);
}
</script>
</body>
</html>