JSFiddle - React, Tailwind, and code Playground

by Denis Plotnikov

JavaScript

var test = '[s-poiler1,Spo_iler2,spoiler3,Spo_iler4]';
var result = test.replace(/([a-z0-9A-Z_\- ]+)/g, "\"$1\"");
console.log(result);
console.log( JSON.parse(result));