I need to edit my css "string" and add #holder selector before every single selector. For example;
I want to change this css string;
/* the css file with comments */
.header ul, .footer #div, .selector3 a
{
box-shadow: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
.selector4, .selector5 ul > li, .selector6 a:hover
{
text-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05) inset;
-moz-text-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05) inset;
-webkit-text-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05) inset;
}
as
/* the css file with comments */
#holder .header ul, #holder .footer #div, #holder .selector3 a
{
box-shadow: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
#holder .selector4, #holder .selector5 ul > li, #holder .selector6 a:hover
{
text-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05) inset;
-moz-text-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05) inset;
-webkit-text-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05) inset;
}
I have used this regex to minify the string and it works fine so you can just ignore the comment lines.
preg_replace('@({)\s+|(\;)\s+|/\*.+?\*\/|\R@is', '$1$2 ', $css);
I'm searching a regex method to do it but any other solution also would be appreciated. Thanks in advance.