str=`【每日一题 2021.12.17】<span lang="EN-US" style="font-size:14.0pt;font-family:"Noto Sans",sans-serif;mso-bidi-font-family:\n等线;mso-bidi-theme-font:minor-fareast" data-mce-style="font-size: 14.0pt; font-family: 'Noto Sans',sans-serif; mso-bidi-font-family: 等线; mso-bidi-theme-font: minor-fareast;">一、<span style="font-size:14.0pt;font-family:等线;\nmso-ascii-font-family:"Noto Sans";mso-fareast-theme-font:minor-fareast;\nmso-hansi-font-family:"Noto Sans";mso-bidi-font-family:"Noto Sans";color:black;\nmso-color-alt:windowtext;background:white" data-mce-style="font-size: 14.0pt; font-family: 等线; mso-ascii-font-family: 'Noto Sans'; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: 'Noto Sans'; mso-bidi-font-family: 'Noto Sans'; color: black; mso-color-alt: windowtext; background: white;">题目已知正整数n是两个不同的质数的乘积,试求出两者中较大的那个质数。[图片]`;
str.replace(/<.+?>/g, "");
我确定正则本身是没问题的,因为别的文本都正常去掉了标签,但就这个文本(我省略了很多)去不掉标签
我怀疑字符串中的 <
和 >
不对,但是不知道啥问题啊
正则表达式中的
.
不匹配换行符,你那个源数据里面有\n