-2

I'm trying to split the following: 116,24|426,776 into two strings upon the | symbol.

My code:

String[] splitString = "116,24|462,776".split("|");
System.out.println(splitString[1]);

However, this code simply returns: 1

Any clues?

Dario
  • 995
  • 1
  • 9
  • 12

1 Answers1

0

You have to use escape character.

Try this String[] splitString = "116,24|462,776".split("\\|");

Here \\ is the escape character.

Please refer http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html

Shreyos Adikari
  • 12,348
  • 19
  • 73
  • 82