|
Biter | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--regexp.REMatch
An instance of this class represents a match completed by a gnu.regexp matching function. It can be used to obtain relevant information about the location of a match or submatch.
Field Summary | |
(package private) int |
anchor
|
(package private) int[] |
count
|
(package private) int[] |
end
|
private String |
m_match
|
(package private) int |
offset
|
(package private) int[] |
start
|
Constructor Summary | |
(package private) |
REMatch(int f_subs,
int f_index)
|
Method Summary | |
(package private) void |
clear(int f_index)
|
(package private) void |
finish(CharIndexed text)
|
int |
getEndIndex()
Returns the index within the input string where the match in its entirety ends. |
int |
getStartIndex()
Returns the index within the input text where the match in its entirety began. |
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. |
(package private) void |
reset(int f_subIndex)
|
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. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private String m_match
int offset
int anchor
int[] start
int[] end
int[] count
Constructor Detail |
REMatch(int f_subs, int f_index)
Method Detail |
void finish(CharIndexed text)
void reset(int f_subIndex)
void clear(int f_index)
public String toString()
REMatch myMatch = myExpression.getMatch(myString);
if (myMatch != null) System.out.println("Regexp found: "+myMatch);
public int getStartIndex()
public int getEndIndex()
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.
public String toString(int sub)
sub
- Index of the subexpression.public int getSubStartIndex(int sub)
-1
if
the subexpression does not exist.sub
- Subexpression indexpublic int getSubEndIndex(int sub)
-1
if
the subexpression does not exist.sub
- Subexpression indexpublic String substituteInto(String input)
$0
through $9
. $0
matches
the full substring matched; $n
matches
subexpression number n.input
- A string consisting of literals and $n
tokens.
|
Biter | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |