let commentText = '你的富文本'
commentText = commentText.replace(/(\n)/g, "");
commentText = commentText.replace(/(\t)/g, "");
commentText = commentText.replace(/(\r)/g, "");
commentText = commentText.replace(/<\/?[^>]*>/g, "");
commentText = commentText.replace(/\s*/g, "");
commentText = commentText.replace(/<[^>]*>/g,"");
commentText = commentText.replace(/ /ig,'');//去掉
效果图:
转前:
转后: