题解 | #字符串通配符#,可以的,又学到了

字符串通配符

http://www.nowcoder.com/practice/43072d50a6eb44d2a6c816a283b02036

import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()){
            String regx = in.next();
            String str = in.next();
            regx = regx.toLowerCase();
            str = str.toLowerCase();
            regx = regx.replaceAll("\\*{2,}","\\*");
            regx = regx.replaceAll("\\?","[0-9a-z]{1}");
            regx = regx.replaceAll("\\*","[0-9a-z]{0,}");
            boolean b = str.matches(regx);
            System.out.println(b);
        }
    }
}
全部评论

相关推荐

二十岁的编程男神王大...:读博吧兄弟,你这绩点太好了,何必转码,另外哈哈哈真见到有括号标出来985的,这个不标注也知道吧
点赞 评论 收藏
分享
评论
2
6
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务