Demonstrates usage of the Pattern split method : Pattern Split « Regular Expressions « Java Tutorial






import java.util.regex.Pattern;

public class MainClass {
  public static void main(String args[]) {
    String statement = "a b c d e f g h i j k l";

    String splitPattern = "e|c|a|a|(a b d e)|(b c e)";

    Pattern p = Pattern.compile(splitPattern);

    String[] tokens = p.split(statement);

    for (int i = 0; i < tokens.length; i++) {
      System.out.println(tokens[i]);
    }
  }
}








8.7.Pattern Split
8.7.1.Demonstrates usage of the Pattern split method