RegExpr3.java Source code

Java tutorial

Introduction

Here is the source code for RegExpr3.java

Source

import java.util.regex.Matcher;
import java.util.regex.Pattern;

class RegExpr3 {
    public static void main(String args[]) {
        Pattern pat = Pattern.compile("test");
        Matcher mat = pat.matcher("test 1 2 3 test");

        while (mat.find()) {
            System.out.println("test found at index " + mat.start());
        }
    }
}