let richText = `< div > test < p > <b> </b></p ></div > `
let reg = /<([a-z]+?)(?:\s+?[^>]*?)?>\s*?<\/\1>/ig;
while (reg.test(richText)) {
richText = richText.replace(reg, "");
}
console.log("1.正则匹配html", richText)
let str = " 546546 4564 46 46 88 88 ";
let strR = str.replace(/\s+/g, "");
console.log('去除空格:', strR);
let input = 12222.0999
const reg2 = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
if (reg2.test(input)) {
console.log('输入数字合法')
} else {
console.log('输入不合法')
}
const strN = "中国移动:10086,中国联通:10010,中国电信:10000";
const regN = /\d{5}/g;
let arrayN = regN.exec(str);
while (arrayN != null) {
console.log(arrayN[0]);
arrayN = regN.exec(strN);
}
console.log('arrayN', arrayN)
console.log('取出数字用math实现:', strN.match(regN))
let sharebyStr = 'lang=en'
let regShare = RegExp(/lang=en/);
if (sharebyStr && sharebyStr.match(regShare)) {
console.log("带参且带lang=en")
} else {
console.log("不带参数")
}