MatchResult Interface

Introduction

The java.util.regex.MatchResult interface represents the result of a match operation. This interface contains query methods used to determine the results of a match against a regular expression. The match boundaries, groups and group boundaries can be seen but not modified through a MatchResult.

Interface declaration

Following is the declaration for java.util.regex.MatchResult interface −

public interface MatchResult

Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career.

Interface methods

Sr.NoMethod & Description
1int end()Returns the offset after the last character matched.
2int end(int group)Returns the offset after the last character of the subsequence captured by the given group during this match.
3String group()Returns the input subsequence matched by the previous match.
4String group(int group)Returns the input subsequence captured by the given group during the previous match operation.
5int groupCount()Returns the number of capturing groups in this match result’s pattern.
6int start()Returns the start index of the match.
7int start(int group)Returns the start index of the subsequence captured by the given group during this match.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *