I’m getting a string from the web looking like this:
Latest Episode@04x22^Killing Your Number^May/15/2009
Then I need to store 04x22, Killing Your Number and May/15/2009 in diffent variables, but it won’t work.
String[] all = inputLine.split("@");
String[] need = all[1].split("^");
show.setNextNr(need[0]);
show.setNextTitle(need[1]);
show.setNextDate(need[2]);
Now it only stores NextNr, with the whole string
04x22^Killing Your Number^May/15/2009
What is wrong?
String.split(String regex)The argument is a regualr expression, and
^has a special meaning there; “anchor to beginning”You need to do:
String[] need = all[1].split("\\^");By escaping the
^you’re saying “I mean the character ‘^’ “