1

I have this string:

var x = "hi<i>zz</i>2<i>bbb</i>";

And want this output:

hizz2bbb

My code not working fine:

value.replace(/\<\i\>/g, '');

Or

value.replace(/\<i>/g, '');
Parsa Nikoo
  • 125
  • 3
  • 11
  • Does this answer your question? [Using jQuery to replace one tag with another](https://stackoverflow.com/questions/7093417/using-jquery-to-replace-one-tag-with-another) – Christopher May 13 '21 at 17:44
  • Does this answer your question? [Strip HTML from Text JavaScript](https://stackoverflow.com/questions/822452/strip-html-from-text-javascript) – Heretic Monkey May 13 '21 at 19:05

3 Answers3

3

This is working for me.

var x = "hi<i>zz</i>2<i>bbb</i>";
x = x.replace(/<\/?i>/g, ""); // hizz2bbb
Charly
  • 83
  • 1
  • 8
1

You can use jQuery for it:

console.log($("<i>hi<i>zz</i>2<i>bbb</i></i>").text())
Andrew
  • 123
  • 1
  • 7
1

This will remove any HTML tags.

x.replace(/<[^>]*>?/gm, '');
MasterOne Piece
  • 413
  • 5
  • 5