package stringtools.tomchaozhou.cuhk; import java.util.*; // Demonstrate Jave String Split examples. public class StringSplitDemo { public static void main(String[] args) { // String to split. String str = "one-two-three|four|five.six.seven.eight|nine.ten"; str = str.trim(); String[] substrs; // delimiter. // | means or. // Special characters needs to be escaped with //: . | String delimiter = "-|//||//."; // Split the given string according the delimiter. substrs = str.split(delimiter); for (int i = 0; i < substrs.length; ++i) { System.out.println(substrs[i]); } } }