Find match by using regular expression - Java Regular Expressions

Java examples for Regular Expressions:Match

Description

Find match by using 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("japanese letter");
    Matcher m = p.matcher(jaText);
    if (m.find()) {
      System.out.println(m.group());
    }//from   w w w.  j  ava2s.  c o  m
  }
}

Related Tutorials