import java.util.*;
import java.util.regex.*;
class test {
public static void main(String[] args) {
String A = "adfffsdfasdfasdfsadf";
String B = "sdf";
Pattern p = Pattern.compile(B);
Matcher m = p.matcher(A);
int count = 0;
while(m.find()){
System.out.printf("下标:%d%n", m.start());
count++;
}
System.out.printf("出现次数:%d", count);
}
}