public static void main(String[] args) {
String s = "I+Love";
s.split("+");
}
这是在线程“main”中抛出异常 java.util.regex.PatternSyntaxException
:
最佳答案
您需要转义+
特殊字符:
s.split("\\+"); // split accepts a regular expression and `+` is a metacharacter
关于java - 如何拆分和分离字符串中包含的加号运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25544423/