我对正则表达式很陌生,我想知道是否有一种方法可以在单行正则表达式中执行此操作
let error = '{"error":"invalid email address"}'
document.write("<p>old: <b>",error,"</b></p>")
error = error.replace(/["\{\}:]/g,'')//this
error = error.replace(/error/g,"")//and this in one line
document.write("<p>new: <b>",error,"</b></p>")
p{
display: block;
}
元芳怎么了
相关分类