com.xmlmind.util
Class RegexMatch

java.lang.Object
  extended by com.xmlmind.util.RegexMatch

public final class RegexMatch
extends java.lang.Object

Input subsequence captured by the given group during the previous match operation. See 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 + "'");
     }
 }


Field Summary
 int endIndex
          Index of the end of the input subsequence.
 int startIndex
          Index of the start of the input subsequence.
 java.lang.String text
          Text contained in the input subsequence.
 
Constructor Summary
RegexMatch(int startIndex, int endIndex, java.lang.String text)
          Constructor.
 
Method Summary
static RegexMatch[] getAll(java.util.regex.Matcher matcher)
          Returns all input subsequence captured during last match operation performed by specified matcher.
 java.lang.String toString()
          Returns text.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 java.lang.String text
Text contained in the input subsequence.

Constructor Detail

RegexMatch

public RegexMatch(int startIndex,
                  int endIndex,
                  java.lang.String text)
Constructor.

Parameters:
startIndex - index of the start of the input subsequence
endIndex - index of the end of the input subsequence
text - text contained in the input subsequence
Method Detail

getAll

public static RegexMatch[] getAll(java.util.regex.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.


toString

public java.lang.String toString()
Returns text.

Overrides:
toString in class java.lang.Object