Javaregex 简明教程
Java Regex - MatchResult Interface
Introduction
java.util.regex.MatchResult 接口表示匹配操作的结果。此接口包含用于确定针对正则表达式的匹配结果的查询方法。匹配边界、组和组边界可以通过 MatchResult 查看,但不能修改。
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
以下是 java.util.regex.MatchResult 接口的声明 −
Following is the declaration for java.util.regex.MatchResult interface −
public interface MatchResult
Interface methods
Sr.No |
Method & Description |
1 |
int end()Returns the offset after the last character matched. |
2 |
int end(int group)Returns the offset after the last character of the subsequence captured by the given group during this match. |
3 |
String group()Returns the input subsequence matched by the previous match. |
4 |
String group(int group)Returns the input subsequence captured by the given group during the previous match operation. |
5 |
int groupCount()Returns the number of capturing groups in this match result’s pattern. |
6 |
int start()Returns the start index of the match. |
7 |
int start(int group)Returns the start index of the subsequence captured by the given group during this match. |