Java examples for Regular Expressions:Pattern
Create classes for the first and last characters so they too can be upper- or lowercase:
import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { Pattern pattern = Pattern.compile("[bB][aAeEiIoOuU][tT]"); Matcher matcher = pattern.matcher("bAt"); if (matcher.matches()) System.out.println("Match."); else/*from ww w . j ava 2s . co m*/ System.out.println("Does not match."); } }