I want to remove the [] signs and whatever inside them in the given string:
const text = "This should [but this should be removed with the brackets] stay intact."
const result = text.replace(/\[.*?\]/g,'')
console.log(result);
The issue is the extra space remain after the removal of brackets.
How can I fix this?