Skip to content

Instantly share code, notes, and snippets.

@skoskie
Last active September 27, 2015 02:58
Show Gist options
  • Save skoskie/1201241 to your computer and use it in GitHub Desktop.
Save skoskie/1201241 to your computer and use it in GitHub Desktop.
CSS Minimizing Regex
(\/\*(.|\s)*?\*\/|(\n|\t|\r|\v|\f|\a){1,}|\s(?=\s)|(?<=})\s|(?<={)\s|\s(?={)|\s(?=})|(?<=;)\s|[[:blank:]](?=;)|(?<=:)[[:blank:]]|(?<=,)[[:blank:]])
@skoskie
Copy link
Author

skoskie commented Sep 7, 2011

You could use this with something like preg_replace() to dynamically minimize css.

@skoskie
Copy link
Author

skoskie commented Jun 24, 2015

Test and modify as needed here: https://regex101.com/r/gI4xR3/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment