尝试2个小时用<br />替换\ r \ n,但这似乎是不可能的。
我不知道我在做什么!请帮忙!
const text = '"Hello!\r\n\r\nThis is a dog!'
const checkText = str=> {
const match = /\r|\n/.exec(text);
if (match) {
//return str.replace(/(?:\\[rn]|[\r\n]+)+/g, '<br/>');
return str.replace('/r/n', '<br/>');
}
return str;
};
checkText(text)
只是这样做:
text.replace(/\r\n/g, '<br/>');
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句