Splitting string with pipe character ("|")
java, regex
Solution
`|` is a metacharacter in regex. You'd need to escape it:
String[] value_split = rat_values.split("\\|");
Problem
I'm not able to split values from this string: `"Food 1 | Service 3 | Atmosphere 3 | Value for money 1 "` Here's my current code: ``` String rat_values = "Food 1 | Service 3 | Atmosphere 3 | Value for money 1 "; String[] value_split = rat_values.split("|"); ``` Output [, 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, ] Expected output Food 1 Service 3 Atmosphere 3 Value for money 1