PatternSplitExample.java Source code

Java tutorial

Introduction

Here is the source code for PatternSplitExample.java

Source

import java.util.regex.Pattern;

public class PatternSplitExample {
    public static void main(String args[]) {
        Pattern p = Pattern.compile(" ");
        String tmp = "this is the String I want to split up";

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

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

    }
}