题解 | #字符串通配符# Java 正则 核心10行
字符串通配符
http://www.nowcoder.com/practice/43072d50a6eb44d2a6c816a283b02036
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String value;
while ((value = bf.readLine()) != null) {
String target = bf.readLine();
value = value.toLowerCase(Locale.ROOT);
target = target.toLowerCase(Locale.ROOT);
String regx = value.replaceAll("\\*{2,}","\\*");
regx = regx.replaceAll("\\?","[0-9a-z]{1}");
regx = regx.replaceAll("\\*","[0-9a-z]{0,}");
System.out.println(target.matches(regx));
}
}
}