JSFiddle - React, Tailwind, and code Playground

by jfriend00

JavaScript

var str = " <style>\n.body{\n width:2px; \n height:3px; \n  } \n</style>"; 
var re = /(\.body\s*\{)([^\}]*?)(\})/m;
var newStyle = "width: 20px; \nheight: 1000px;";
var result = str.replace(re, "$1" + newStyle + "$3");
alert(result);