Matcher reset() Method in Java with Examples Last Updated : 25 Apr, 2023 Comments Improve Suggest changes Like Article Like Report The reset() method of Matcher Class is used to reset this matcher, in order to understand it better it is recommended to have prior knowledge of Pattern and Matcher class in java regex sub-package. Here we will be illustrating it with help of Java programs. Syntax: public Matcher reset() Parameters: This method does not take any parameters. Return Value: This method returns this Matcher after being reset. Example 1: Java // Java Program to illustrate reset() method // of Matcher class // Importing class from java.util.regex package // where regex is a subpackage import java.util.regex.*; // Main class public class GFG { // Main driver method public static void main(String[] args) { // Getting the regex to be checked // taking via string input String regex = "Geeks"; // Creating a pattern from regex // using Pattern class Pattern pattern = Pattern.compile(regex); // Getting the String to be matched String stringToBeMatched = "GeeksForGeeks"; // Creating a matcher for the input String // using Matcher class Matcher matcher = pattern.matcher(stringToBeMatched); // Resetting the Matcher using reset() method matcher = matcher.reset(); // Getting the current matcher state // using tomatchResult() method and // printing it System.out.println(matcher.toMatchResult()); } } Outputjava.util.regex.Matcher$ImmutableMatchResult@448139f0 Example 2: Java // Java Program to Illustrate reset() method // of Matcher class // Importing class from java.util.regex package // where regex is a subpackage import java.util.regex.*; // Main class public class GFG { // Main driver method public static void main(String[] args) { // Getting the regex to be checked String regex = "GFG"; // Creating a pattern from regex Pattern pattern = Pattern.compile(regex); // Getting the String to be matched String stringToBeMatched = "GFGFGFGFGFGFGFGFGFG"; // Creating a matcher for the input String Matcher matcher = pattern.matcher(stringToBeMatched); // Resetting the Matcher // using reset() method matcher = matcher.reset(); // Getting the current matcher state // using toMatchResult() method System.out.println(matcher.toMatchResult()); } } Outputjava.util.regex.Matcher$ImmutableMatchResult@448139f0 Comment More infoAdvertise with us Next Article Matcher reset() 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 start() method in Java with Examples The start() method of Matcher Class is used to get the start index of the match result already done. Syntax: public int start() Parameters: This method do not takes any parameter. Return Value: This method returns the index of the first character matched.0 Exception: This method throws IllegalStateE 2 min read LogManager reset() method in Java with Examples The reset() method of java.util.logging.LogManager is used to reset the logging configuration. This method throws SecurityException if the exception condition occurs, as given below Syntax: public void reset() throws SecurityException Parameters: This method does not accepts any parameter. Return Va 1 min read Matcher toMatchResult() method in Java with Examples The toMatchResult() method of Matcher Class is used to get the current result state of this Matcher. Syntax: public MatchResult toMatchResult() Parameters: This method do not takes any parameter. Return Value: This method returns a MatchResult with the current match result state of this Matcher. Bel 2 min read LongAdder reset() method in Java with Examples LongAdder class in Java creates a new adder with an initial sum of zero. The Java.LongAdder.reset() is an inbuilt method in Java that resets the sum to zero. When the object of the class is created its initial value is zero. Syntax: public void reset() Parameters: The function does not accepts any p 2 min read Matcher reset(CharSequence) method in Java with Examples The reset(CharSequence input) method of Matcher Class is used to reset this matcher and insert the input String passed as the parameter to this matcher. Syntax: public Matcher reset(CharSequence input) Parameters: This method takes the parameter input which is the String to be inserted into matcher 2 min read Like