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); } }
效果图:
好了.