正则表达式练习20200108之匹配不区分大小写字母的字符串

package org.jimmy.autosearch.test;

import java.util.regex.Pattern;

public class RegexTest2020010701 {

    private static Pattern musicReg = Pattern.compile("(?i)[.]mp3");
    
    public static void main(String[] args) {
        String test = ".mp3";
        boolean result = musicReg.matcher(test).matches();
        System.out.println(result);
        test = ".Mp3";
        result = musicReg.matcher(test).matches();
        System.out.println(result);
        test = ".MP3";
        result = musicReg.matcher(test).matches();
        System.out.println(result);
        test = "a.MP3";
        result = musicReg.matcher(test).matches();
        System.out.println(result);
    }

}

效果图:

 

 好了.

posted @ 2020-01-08 10:55  ラピスラズリ(Dawn)  阅读(319)  评论(0编辑  收藏  举报