java 正则表达式,多个星号可以认为是一个通配符,因为*匹配0个或多个,这样可以减少运行时间
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNextLine()) {
String regx = sc.nextLine().toLowerCase();
String target = sc.nextLine().toLowerCase();
regx = regx.replaceAll("\\?","[0-9a-z]{1}");
regx = regx.replaceAll("\\*+","[0-9a-z]{0,}");
regx =regx.replaceAll("\\.","\\\\.");
System.out.println(target.matches(regx));
}
}
}