1、只获取数字或字母
<script>
var str = "abc123";
var reg = /[^abc]/g;
console.log(str.replace(reg,"*"));
var test = "?@hello123-";
var reg = /[^\d]/g
console.log(test.replace(reg,"*"))
</script>
1.1、只获取数字
<script>
var str = "<span>2395人参观</span>-<span>46人评价</span>"
var reg = /[^\d-]/g;
var res = str.replace(reg,"");
console.log(res.split("-"));
</script>
2、过滤标签
var reg = /<[^<>]+>/g
<script>
var str = "<p>塞斯额啊</p><br/><span>666</span>"
var reg = /<[^<>]+>/g //html标签的正则
console.log(str.replace(reg,""))
</script>