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