MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

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]);
        }
    }
}