Matcher find(int) method in Java with Examples Last Updated : 26 Nov, 2018 Comments Improve Suggest changes Like Article Like Report The find(int start) method of Matcher Class attempts to find the next subsequence after the specified subsequence number, passed as parameter, of the input sequence that find the pattern. It returns a boolean value showing the same. Syntax: public boolean find(int start) Parameters: This method takes a parameter start which is the subsequence number after which the next subsequence is to be found. Return Value: This method returns a boolean value showing whether a subsequence of the input sequence find this matcher's pattern Exception: This method throws IndexOutOfBoundsException if start is less than zero or greater than the length of the input sequence. Below examples illustrate the Matcher.find() method: Example 1: Java // Java code to illustrate find() method import java.util.regex.*; public class GFG { public static void main(String[] args) { // Get the regex to be checked String regex = "Geeks"; // Create a pattern from regex Pattern pattern = Pattern.compile(regex); // Get the String to be matched String stringToBeMatched = "GeeksForGeeks"; // Create a matcher for the input String Matcher matcher = pattern .matcher(stringToBeMatched); // Get the subsequence // using find() method System.out.println(matcher.find(1)); } } Output: true Example 2: Java // Java code to illustrate find() method import java.util.regex.*; public class GFG { public static void main(String[] args) { // Get the regex to be checked String regex = "GFG"; // Create a pattern from regex Pattern pattern = Pattern.compile(regex); // Get the String to be matched String stringToBeMatched = "GFGFGFGFGFGFGFGFGFG"; // Create a matcher for the input String Matcher matcher = pattern .matcher(stringToBeMatched); // Get the subsequence // using find() method System.out.println(matcher.find(0)); } } Output: true Reference: Oracle Doc Comment More infoAdvertise with us Next Article Matcher find(int) method in Java with Examples K Kirti_Mangal Follow Improve Article Tags : Java Java - util package Java-Functions Java-Matcher Practice Tags : Java Similar Reads Matcher find() method in Java with Examples The find() method of Matcher Class attempts to find the next subsequence of the input sequence that find the pattern. It returns a boolean value showing the same. Syntax: public boolean find() Parameters: This method do not takes any parameter. Return Value: This method returns a boolean value showi 2 min read Matcher hitEnd() method in Java with Examples The hitEnd() method of Matcher Class is used to check if this the matching of the pattern on this matcher has stopped or not. The matching ends when no more matched group is found in the matcher. This method returns a boolean value stating the same. Syntax: public boolean hitEnd() Parameters: This m 3 min read Matcher end(int) method in Java with Examples The end(int group) method of Matcher Class is used to get the offset after the end index of the match result already done, from the specified group. Syntax: public int end(int group) Parameters: This method takes a parameter group from which the offset after the end index of the matched pattern is r 2 min read Matcher region(int, int) method in Java with Examples The region(int, int) method of Matcher Class restricts the region to be matched by the pattern. This region must be lesser than or same as the previous region, but not greater. Else it would lead to IndexOutOfBoundsException. This method returns a Matcher with the new matching region. Syntax: public 3 min read Matcher group(int) method in Java with Examples The group(int group) method of Matcher Class is used to get the group index of the match result already done, from the specified group. Syntax: public String group(int group) Parameters: This method takes a parameter group which is the group from which the group index of the matched pattern is requi 2 min read Like