Match string with regular expression - Java Regular Expressions

Java examples for Regular Expressions:Match

Description

Match string with regular expression

Demo Code

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
  private String jaText = "this is a test ";


  public Main() {
    Pattern p = Pattern.compile(".at");
    Matcher m = p.matcher(jaText);
    while (m.find()) {
      System.out.printf("%s\n", m.group());
    }// ww w  .j  av a2s  .  co  m
  }
}

Related Tutorials