The Java official documentation states:
The string \"boo:and:foo\", for example, yields the following results with these expressions Regex Result :
\"boo:and:foo\"
Use this code:
public static void main(String[] args) { String test = "A|B|C||D"; String[] result = test.split("\\|"); for (String s : result) { System.out.println(">" + s + "<"); } }