Finding Text Matches with regular expressions and the String matches() helper method to determine how many matches exist. - Java Language Basics

Java examples for Language Basics:String

Description

Finding Text Matches with regular expressions and the String matches() helper method to determine how many matches exist.

Demo Code

public class Main {
  public static void main(String[] args) throws Exception {
    String str = "Here";
 
    boolean result = str.matches("Here");
    System.out.println(result);//from  w  w w. j  a  v a 2s.  c  om
 
    result = str.matches("Here is a long String...");
    System.out.println(result);
  }
}

Result


Related Tutorials