public final class RegexMatch extends Object
java.util.regex.Matcher.
Example of use:
Pattern p = Pattern.compile(regexp);
Matcher matcher = p.matcher(string);
if (matcher.matches()) {
RegexMatch[] match = RegexMatch.getAll(matcher);
for (int j = 0; j < match.length; ++j) {
System.out.println("\t$" + j + "='" + match[j].text + "'");
}
}| Modifier and Type | Field and Description |
|---|---|
int |
endIndex
Index of the end of the input subsequence.
|
int |
startIndex
Index of the start of the input subsequence.
|
String |
text
Text contained in the input subsequence.
|
| Constructor and Description |
|---|
RegexMatch(int startIndex,
int endIndex,
String text)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static RegexMatch[] |
getAll(Matcher matcher)
Returns all input subsequence captured during last match operation
performed by specified matcher.
|
String |
toString()
Returns
text. |
public final int startIndex
public final int endIndex
public final String text
public RegexMatch(int startIndex,
int endIndex,
String text)
startIndex - index of the start of the input subsequenceendIndex - index of the end of the input subsequencetext - text contained in the input subsequencepublic static RegexMatch[] getAll(Matcher matcher)
Returned array is empty if matcher has never been used or if input sequence does not match pattern.