-2

Replace <b> and </b> with space " " and <br> with \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>[email protected]<br><b>Password : </b>qwerty";

var b = a.replace("<b>|</b>"," ").replace("<br>","\n");
console.log(b);
4
  • 2
    "<b>|</b>" replaces literal strings "<b>|</b>". You need a regex here. Commented Jul 12, 2018 at 5:50
  • could you please provide a code for that @Xufox Commented Jul 12, 2018 at 5:51
  • /<b>|<\/b>/g. Commented Jul 12, 2018 at 6:00
  • var a = "Welcome to xyz. You have been added as a manager by <b>Adam </b>.<br><br><b>Dashboard Link:</b> app.xyz.com <br><br>Use the credentials below to sign-in: <br><b>Username : </b>[email protected]<br><b>Password : </b>qwerty"; var b = a.replace(/<b>|<\/b>/g," ").replace(/<br>/g,"\n"); console.log(b); worked Commented Jul 12, 2018 at 8:56

1 Answer 1

0

@repeated see this you can use regular expression or slit and joint function to achieve it.for multiple character use regex

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.