Guest User

JS Whitespace stripper

a guest
Apr 11th, 2010
750
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $output = preg_replace_callback(
  2.     '#//[^\n]*|/\*.*?\*/|/(?!\s)(?:\\\\.|[^/\\\\])*/|\'(?:\\\\.|[^\'\\\\])*\'|"(?:\\\\.|[^"\\\\])*"|\s*[^0-9a-z_$\'"/\s]\s*|\s+#si',
  3.     function($m) {
  4.         $m = trim($m[0]);
  5.         return $m === '' ? ' ' : ($m[0] === '/' && ($m[1] === '*' || $m[1] === '/') ? '' : $m);
  6.     },
  7.     $input);
RAW Paste Data