正则表达式练习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);
    }

}

效果图:

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

 

 好了.

上一篇:php mysql字段 驼峰, 小写 互转


下一篇:SpringBoot中ConditionalOnClass注解的原理