java.util.regex.PatternSyntaxException: Syntax error U_REGEX_RULE_SYNTAX near index 1
str = bundle.getString("location").split("+");
改为
str = bundle.getString("location").split("\\+");
或者
str = bundle.getString("location").split("[+]");
本文解决了一个Java中利用正则表达式进行字符串分割时出现的PatternSyntaxException错误。通过修改split方法中的正则表达式,从使用+更改为\+或[+],成功避免了语法错误。
java.util.regex.PatternSyntaxException: Syntax error U_REGEX_RULE_SYNTAX near index 1
str = bundle.getString("location").split("+");
改为
str = bundle.getString("location").split("\\+");
或者
str = bundle.getString("location").split("[+]");
4099
4037
5868
2196

被折叠的 条评论
为什么被折叠?