【发布时间】:2020-04-26 12:47:30
【问题描述】:
str 是一个 html 字符串(或包含完整 html 的字符串),但中间有一些我试图摆脱的不需要的代码。
到目前为止,这对我有用:
const contentClean = str.replace(/=0A/gm,"").replace(/(=09)/gm,"").replace(/(=\r\n)/gm,"").replace(/(3D)/gm,"");
如何在上面的代码中只编写一次 replace() 方法而不是 4 次?
【问题讨论】:
标签: javascript string replace str-replace regexp-replace