{};,)])/S', '$1', $matches[6]); // Clean pre-punctuation. $matches[6] = preg_replace('/([+>{}:;,(])\s++/S', '$1', $matches[6]); // Clean post-punctuation. $matches[6] = preg_replace('/;?\}/S', "}\n", $matches[6]); // Add a touch of formatting. return "\n/*T2\\*/" . $matches[6] . "\n/*T2E*/\n"; // Minify and reassemble composite type2 comment. } elseif (isset($matches[8])) { // Group 8: Non-string, non-comment. Safe to clean whitespace here. $matches[8] = preg_replace('/^\s++/', '', $matches[8]); // Strip all leading whitespace. $matches[8] = preg_replace('/\s++$/', '', $matches[8]); // Strip all trailing whitespace. $matches[8] = preg_replace('/\s{2,}+/', ' ', $matches[8]); // Consolidate multiple whitespace. $matches[8] = preg_replace('/\s++([+>{};,)])/S', '$1', $matches[8]); // Clean pre-punctuation. $matches[8] = preg_replace('/([+>{}:;,(])\s++/S', '$1', $matches[8]); // Clean post-punctuation. $matches[8] = preg_replace('/;?\}/S', "}\n", $matches[8]); // Add a touch of formatting. return $matches[8]; } return $matches[0] . "\n/* ERROR! Unexpected _proccess_css_minify() parameter */\n"; // never get here } // Write minified css to new file appending "_min" to the filename. $outputfilename = preg_replace('/(.*)(\.[^.]+)/', '$1_min$2', $argv[1]); file_put_contents($outputfilename, $contents); ?>