Create classes for the first and last characters so they too can be upper- or lowercase: - Java Regular Expressions

Java examples for Regular Expressions:Pattern

Description

Create classes for the first and last characters so they too can be upper- or lowercase:

Demo Code

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.");
  }
}

Related Tutorials