How to remove square brackets in string using regex?

Use this regular expression to match square brackets or single quotes:

/[\[\]']+/g

Replace with the empty string.

console.log("['abc','xyz']".replace(/[\[\]']+/g,''));

Leave a Comment