提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
让模式包括大写字母和小写字母
//nowjava - 时代Java import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { Pattern pattern = Pattern.compile("b[aAeEiIoOuU]t"); Matcher matcher = pattern.matcher("bAt"); if (matcher.matches()) System.out.println("Match."); else System.out.println("Does not match."); } }