[test]", then after removing square brackets I should get "
var WithOutBrackets="[test]".replace(/[\[\]']+/g,''); console.log(WithOutBrackets); //test
Addtionally if you string is something like below
var strWithBrackets= "[br549 ]  [fkrig 009] [ ] [ 01 ]";
You can change your Regex and make it like
var newString= "[br549 ]  [fkrig 009] [ ] [ 01 ] ".replace(/\s|\[|\]/g,""); console.log(mynewstring);
So,basically output depends on your input string and regex.
You can also try '
str.replace(/[[\]]/g,'')' to remove '[' ']' brackets from string.
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly