(?s)\s|/\*.*?\*/
I've tested with ColdFusion 8 and Railo 3.3.
sCSSContent= sCCSContent.ReplaceAll( "(?s)\s|/\*.*?\*/" , "" );
/* Test 1 */
/* Test * / * 2 */
/* Test
. test
. test
test 3
*/
/* Test * / * 4 */ width: 0; /* Test 5 *//**/
/* Test 6 /*/
Hmmm, I think you're a bit confused - Java does do negative character classes (
[^abc]matches anything exceptaorborc), and negative lookaheads ((?!abc)- matches any position not followed byabcstring) - the latter is what you were attempting to do (with mixed up syntax), and would be/\*(?:(?!\*/).)*+\*/if you were going to do it that way, but yeah - the simpler solution in this case is a lazy quantifier.Have you tested against multi-line comments? By default
.wont match a newline, so you may need to enable "dotall" mode, which can be done by placing a(?s)at the start of the pattern.(The
sis because other regex implementations call it "single-line" mode, just to be confusing.)