Javascript替换字符串中的多个字符无法正常工作

时间:2018-07-12 05:49:58

标签: javascript

<b></b>替换为空格“”将<br>替换为\ n

var a  = "Welcome to xyz. You have been added as a manager by <b>Adam </b>.<br><br><b>Dashboard Link:</b> https://app.xyz.com <br><br>Use the credentials below to sign-in: <br><b>Username : </b>a@k.com<br><b>Password : </b>qwerty";

var b = a.replace("<b>|</b>"," ").replace("<br>","\n");
console.log(b);

1 个答案:

答案 0 :(得分:0)

@repeated see this,您可以使用正则表达式或狭缝和关节函数来实现。对于多字符,请使用正则表达式