Hello, the function receives the following text:

hello world, this is message, welcome to <a href="site.ru">site.ru</a> we are bla bla bla. <br><br class="br"> good bye! 

How to make such a text such (then returning):

  hello world, this is message, welcome to site.ru we are bla bla bla. good bye! 

that is, we cut the html code from the link, leaving only the link text itself, and <br и <br class="br"> заменяем на перенос строки \n

thank

    1 answer 1

     const text = 'hello world, this is message, welcome to <a href="site.ru">site.ru</a> we are bla bla bla. <br><br class="br"> good bye!'; const s = document.createElement('span'); s.innerHTML = text; console.log(s.innerText); 

    • How do I understand your version of fully formatted HTML tags? but you can do something similar, only to mention the links and br that are given in the question - turik97