Package com.xmlmind.util
Class RegexMatch
- java.lang.Object
-
- com.xmlmind.util.RegexMatch
-
public final class RegexMatch extends Object
Input subsequence captured by the given group during the previous match operation. Seejava.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 + "'"); } }
-
-
Field Summary
Fields Modifier and Type Field 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 Summary
Constructors Constructor Description RegexMatch(int startIndex, int endIndex, String text)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RegexMatch[]
getAll(Matcher matcher)
Returns all input subsequence captured during last match operation performed by specified matcher.String
toString()
Returnstext
.
-
-
-
Field Detail
-
startIndex
public final int startIndex
Index of the start of the input subsequence.
-
endIndex
public final int endIndex
Index of the end of the input subsequence.
-
text
public final String text
Text contained in the input subsequence.
-
-
Constructor Detail
-
RegexMatch
public RegexMatch(int startIndex, int endIndex, String text)
Constructor.- Parameters:
startIndex
- index of the start of the input subsequenceendIndex
- index of the end of the input subsequencetext
- text contained in the input subsequence
-
-
Method Detail
-
getAll
public static RegexMatch[] getAll(Matcher matcher)
Returns all input subsequence captured during last match operation performed by specified matcher.Returned array is empty if matcher has never been used or if input sequence does not match pattern.
-
-