Skip to content

Instantly share code, notes, and snippets.

@orangexception
Created October 17, 2011 14:53
Show Gist options
  • Save orangexception/1292778 to your computer and use it in GitHub Desktop.
Save orangexception/1292778 to your computer and use it in GitHub Desktop.
Minify CSS Regular Expression

Regular Expression

(?s)\s|/\*.*?\*/

Usage in ColdFusion

I've tested with ColdFusion 8 and Railo 3.3.

sCSSContent= sCCSContent.ReplaceAll( "(?s)\s|/\*.*?\*/" , "" );

Test Cases

/* Test 1 */
/* Test * / * 2 */
/* Test
. test
. test

test 3
*/
/* Test * / * 4 */ width:	0; /* Test 5 *//**/
/* Test 6 /*/
@boughtonp
Copy link

Still not sure where "negative groups" is coming from - I've not heard that term, nor seen the syntax [^(abc)] except as a negative character class (any char except those five) - not in Java/Python/Perl/PCRE or any others I'm aware of. Have you got a reference for it?

@orangexception
Copy link
Author

I don't have a reference offhand. Perhaps it's something floating in my brain from formal languages. It'd be rather handy. I know this isn't the first time I've tried to use it.

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