Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这个正则表达式,它试图将预定义的字符类\s与,结合起来:
String rgx = "[^\s,]"
但是我得到一个错误,说 \s 是一个非法的转义字符。我不能双反斜杠\s,因为如果我这样做,那么字符类将被解释为反斜杠和字母's'。我能做些什么?
在 java 中,您必须对预定义的类进行双重转义。
String rgx = "[^\\s,]";