Let the pattern include uppercase letters as well as lowercase letters - Java Regular Expressions

Java examples for Regular Expressions:Pattern

Description

Let the pattern include uppercase letters as well as lowercase letters

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("b[aAeEiIoOuU]t");
    Matcher matcher = pattern.matcher("bAt");
    if (matcher.matches())
      System.out.println("Match.");
    else/*from w  ww  . j  a  va2s .  c  om*/
      System.out.println("Does not match.");
  }
}

Related Tutorials