We\'d like to convert a CSS style entered as string into a JS object.
E.g.,
var input = \" border:solid 1px; color:red \";
expec
something like this should get you pretty close:
var input = " border:solid 1px; color:red "; var output = '{' + input.replace(/([\w-.]+)\s*:([^;]+);?/g, '\n $1:"$2",') + '\n}';
...turns
" border:solid 1px; color:red "
into
{ border:"solid 1px", color:"red ", }