<script> let string = 'текст1 [USER=4895]текст2[/USER] текст3 [DISK FILE ID=57753] текст4 '; function remove_bbcode(string) { const pattern = /\[[^\]]+\]/g; return string.replace(pattern, ''); } document.write(remove_bbcode(string)) </script>