gnu.regexp
public final class REMatch extends Object implements Serializable, Cloneable
Field Summary | |
---|---|
int | anchor |
int | eflags |
int[] | end |
int | index |
REMatch | next |
int | offset |
int[] | start |
Constructor Summary | |
---|---|
REMatch(int subs, int anchor, int eflags) |
Method Summary | |
---|---|
void | assignFrom(REMatch other) |
void | clear(int index) Clears the current match and moves the offset to the new index. |
Object | clone() |
void | finish(CharIndexed text) |
int | getEndIndex()
Returns the index within the input string where the match in
its entirety ends. |
int | getEndIndex(int sub)
Returns the index within the input string used to generate this match
where subexpression number sub ends, or -1 if
the subexpression does not exist. |
int | getStartIndex()
Returns the index within the input text where the match in its entirety
began. |
int | getStartIndex(int sub)
Returns the index within the input string used to generate this match
where subexpression number sub begins, or -1 if
the subexpression does not exist. |
int | getSubEndIndex(int sub)
Returns the index within the input string used to generate this match
where subexpression number sub ends, or -1 if
the subexpression does not exist. |
int | getSubStartIndex(int sub)
Returns the index within the input string used to generate this match
where subexpression number sub begins, or -1 if
the subexpression does not exist. |
String | substituteInto(String input)
Substitute the results of this match to create a new string.
|
String | toString()
Returns the string matching the pattern. |
String | toString(int sub)
Returns the string matching the given subexpression. |
REMatch myMatch = myExpression.getMatch(myString);
can be viewed (given that myMatch is not null) by creating
String theMatch = myString.substring(myMatch.getStartIndex(),
myMatch.getEndIndex());
But you can save yourself that work, since the toString()
method (above) does exactly that for you.
-1
if
the subexpression does not exist. The initial position is zero.
Parameters: sub Subexpression index
-1
if
the subexpression does not exist. The initial position is zero.
Parameters: sub Subexpression index
Since: gnu.regexp 1.1.0
Deprecated: Use getEndIndex(int) instead
Returns the index within the input string used to generate this match where subexpression number sub ends, or-1
if
the subexpression does not exist. The initial position is zero.
Parameters: sub Subexpression index
Deprecated: Use getStartIndex(int) instead.
Returns the index within the input string used to generate this match where subexpression number sub begins, or-1
if
the subexpression does not exist. The initial position is zero.
Parameters: sub Subexpression index
$0
through $9
. $0
matches
the full substring matched; $n
matches
subexpression number n.
Parameters: input A string consisting of literals and $n
tokens.
REMatch myMatch = myExpression.getMatch(myString);
if (myMatch != null) System.out.println("Regexp found: "+myMatch);
Parameters: sub Index of the subexpression.