常用正则
去除字符串空格
var str = ' qdleader like u';
console.log(str.replace(/\s/ig,''))
身份证号码
var Card = /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;
手机号
let phone = /^[1][3,4,5,7,8][0-9]{9}$/;
手写trim
String.prototype.trim = function () {
return this.replace(/^\s+/,'').replace(/\s+$/,'')
}
去除富文本
let data =document.getElementById(aa).innerHTML;
data = data.replace(/(\n)/g, "");
data = data.replace(/(\t)/g, "");
data = data.replace(/(\r)/g, "");
data = data.replace(/<\/?[^>]*>/g, "");
data = data.replace(/\s*/g, "");
将html标签替换为空字符串
str.replace(/(<(.[^>]*)>)|( )/g,"")