To remove [
and ]
from start/end of a string (if both are present) you need
In JS, to match any symbol including a newline, you either use [\s\S]
(or [\w\W]
or [\d\D]
), or [^]
that matches any non-not
const names = "[Tools Missing, Major Issue, Special Tools Required, Spares Required]";
const test = names.replace(/[\[\]']+/g,'');
console.log(test)
output = Tools Missing, Major Issue, Special Tools Required, Spares Required