我无法从此字符串拆分值:
"Food 1 | Service 3 | Atmosphere 3 | Value for money 1 "
这是我当前的代码:
String rat_values = "Food 1 | Service 3 | Atmosphere 3 | Value for money 1 "; String[] value_split = rat_values.split("|");
| 输出量
[,F,o,o,d,,1,,|,,S,e,r,v,i,c,e,,3,,|,,A,t,m,o,s,p, h,e,r,e,,3,,|,,V,a,l,u,e,,f,o,r,,m,o,n,e,y,,1,]
预期产量
Food 1 Service 3 Atmosphere 3 Value for money 1
|是正则表达式中的元字符。你需要对其进行转义:
|
String[] value_split = rat_values.split("\\|");