replaceFontSize(html, newSize) {//html :存储的文本信息 ;newSize:新的font-size
if(html){
const regex = /style="([^"]*)(font-size:[^;"]*)([^"]*);?/g;
return html.replace(regex, (match, prefix, fontSize, suffix) => {
let newStyle = "";
if (prefix) {
newStyle += prefix;
}
newStyle += `font-size: ${newSize};`;
if (suffix) {
newStyle += suffix.replace(/;$/, "");
}
if (!suffix && match.endsWith(";")) {
newStyle += ";";
}
return `style="${newStyle}"`;
});
}
},