Pergunta

I am trying to cleanup my CSS documents to remove only those vendor-prefixed lines:

-webkit-......;
-o-.....;
-ms-......;
-khtml-......;
-moz-......;

As you see all lines have the same patterns ended with semi-colons, only different vendors. So far I tried with searching one by one, but there should a better way to achieve this:

preg_match("/(-webkit.*;)/", $css, $webkit);
$css = str_replace($webkit[1], '', $css);
// ... etc

Any hint would be very much appreciated. Thanks

UPDATE: The reason is I will use http://leaverou.github.com/prefixfree/, but I need a way to toggle the states for certain phase of developments, like when JS disabled.

Foi útil?

Solução

try this regex /^-.*;?/m matches every line that starts with -, and possible have a ; at the end
updated
/^(\s|\t)*-.*;?/m match anything that starts with no or more whitespace or tab, has - after whitespace or tab and ends with at exactly one ;

Outras dicas

Try this (-webkit-.*?;)|(-khtml-.*?;)|(-ms-.*?;)|(-moz-.*?;)|(-o-.*?;)

preg_match("/(-webkit-.*?;)|(-khtml-.*?;)|(-ms-.*?;)|(-moz-.*?;)|(-o-.*?;)/", $css, $webkit);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top