public interface

MatchResult

java.util.regex.MatchResult
Known Indirect Subclasses

Class Overview

Holds the results of a successful match of a Pattern against a given string. The result is divided into groups, with one group for each pair of parentheses in the regular expression and an additional group for the whole regular expression. The start, end, and contents of each group can be queried.

Summary

Public Methods
abstract int end()
Returns the index of the first character following the text that matched the whole regular expression.
abstract int end(int group)
Returns the index of the first character following the text that matched a given group.
abstract String group()
Returns the text that matched the whole regular expression.
abstract String group(int group)
Returns the text that matched a given group of the regular expression.
abstract int groupCount()
Returns the number of groups in the result, which is always equal to the number of groups in the original regular expression.
abstract int start()
Returns the index of the first character of the text that matched the whole regular expression.
abstract int start(int group)
Returns the index of the first character of the text that matched a given group.

Public Methods

public abstract int end ()

Returns the index of the first character following the text that matched the whole regular expression.

Returns
  • the character index.

public abstract int end (int group)

Returns the index of the first character following the text that matched a given group.

Parameters
group the group, ranging from 0 to groupCount() - 1, with 0 representing the whole pattern.
Returns
  • the character index.

public abstract String group ()

Returns the text that matched the whole regular expression.

Returns
  • the text.

public abstract String group (int group)

Returns the text that matched a given group of the regular expression.

Parameters
group the group, ranging from 0 to groupCount() - 1, with 0 representing the whole pattern.
Returns
  • the text that matched the group.

public abstract int groupCount ()

Returns the number of groups in the result, which is always equal to the number of groups in the original regular expression.

Returns
  • the number of groups.

public abstract int start ()

Returns the index of the first character of the text that matched the whole regular expression.

Returns
  • the character index.

public abstract int start (int group)

Returns the index of the first character of the text that matched a given group.

Parameters
group the group, ranging from 0 to groupCount() - 1, with 0 representing the whole pattern.
Returns
  • the character index.