I have a JavaScript variable:
var s =
"<html><head><style>body{a:b;c:d}</style></head><body></body></html>";
First, I am extracting the content inside <style> tags:
s = s.split(/(<style[^>]*>|<\/style>)/i)[2];
// s == "body{a:b;c:d}";
Then I am doing something with s and after the manipulation I need to append it on <style> tags.
How can I insert s between <style> and </style> ?
Example: Modified var s = "body{x:h;f:l;}";
so I need the resulting content like this:
"<html><head><style>body{x:h;f:l;}</style></head><body></body></html>";
Update: jQuery is allowed - But only string manipulation is allowed. Pure JavaScript solutions have first priority.