import java.util.*;
import java.lang.*;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
String A = sc.next();
String B = sc.next();
if(A.length() == 0){
System.out.println(0);
return;
}
Set<String> set = new HashSet<>();
从A的每一位开始找以当前i位置开头的字符串是否有和B匹配的
for(int i = 0;i <= A.length() - B.length();i++){
StringBuilder sb = new StringBuilder();
遍历B字符串
for(int j = 0;j < B.length();j++){
当B不为? 或者 和A字符串中i位置匹配时
因为是以i开头,所以A中与B比较的字符为i+j
if(B.charAt(j) == '?' || B.charAt(j) == A.charAt(i+j)){
sb.append(A.charAt(i+j));
}else break;
}
if(sb.toString().length() == B.length()) set.add(sb.toString());
}
System.out.println(set.size());
}
}
09-29
307
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-21
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)