# Notice Do not run this against minified JavaScript packages. The minified packages often rely on line returns to execute correctly. This regular expression was designed to minify simple JavaScript. # Regular Expression `(?s)[\t\r\n]|[ ][ ]+|/\*.*?\*/*` I put spaces in square brackets as a reminder that they exist. Spaces can be important. For example, `$( "#foo #bar" )` should not become `$("#foo#bar")`. However, we do want to remove spaces if they are used for indentation. I'm having trouble removing // comments due to values such as "http://." # Usage in ColdFusion `sJavaScriptContent= sJavaScriptContent.ReplaceAll( "(?s)\s|/\*.*?\*/|//[^\r\n]*" , "" );` # Test Cases ``` // Test 0 /* Test 1 */ /* Test * / * 2 */ /* Test . test . test test 3 */ /* Test * / * 4 */ /* Test 5 *//**/ /* Test 6 /*/ // Test 7 /* Test // 8 */ // ////// Test 9 // */ Test 10 $( "#foo #bar" ).val( "Test 11 - This value should exist." ); $( "#foo #bar" ).val( "http://orangexception.com/" ); // Test 12 - http:// should exist. However, this comment should not exist. // // Test 13 - This line should be gone. http://orangexception.com/foo/bar/ ```