If you insist on a regular expression as the answer, you could use the following.
str = str.replace(/\s*<ul[^>]*>[\S\s]*?<\/ul>\s*/, '');
Вопрос
how i can remove with js the ul tags and all the content? example
<div>
<ul>
<li>a</li>
<li>b</li>
</ul>
</div>
i want this
<div></div>
i use
var.replace('regex', '');
anyone can help me?
Ps. only js, i can't use Jquery
Решение
If you insist on a regular expression as the answer, you could use the following.
str = str.replace(/\s*<ul[^>]*>[\S\s]*?<\/ul>\s*/, '');
Другие советы
Why use regex when you can use dom parsing?
var ul = document.getElementsByTagName('ul')[0];
ul.parentElement.removeChild(ul)