Java regex predefined character class?

I have a regular expression that tries to combine predefined character class \ s with , :

String rgx = "[^\s,]"

But I get an error that \ s is an illegal escape character. I cannot double the \ s backslash because if I do this, the character class will be interpreted as a backslash and the letter 's'. What can I do?

+4
source share
1 answer

In java, you must double access to predefined classes.

String rgx = "[^\\s,]";
+6
source

All Articles