import java.util.regex.*; class Samp02 { public static void main(String[] args){ Pattern p = Pattern.compile("aba"); Matcher m = p.matcher("abababa"); int start = 0; while(m.find(start)){ System.out.printf("%d:%s\n", m.start(), m.group()); start = m.start() + 1; } } }