public final class REMatch extends Object implements Serializable, Cloneable
Modifier and Type | Field and Description |
---|---|
(package private) int |
anchor |
(package private) int |
eflags |
(package private) int[] |
end |
(package private) int |
index |
private String |
matchedText |
(package private) REMatch |
next |
(package private) int |
offset |
(package private) int[] |
start |
Constructor and Description |
---|
REMatch(int subs,
int anchor,
int eflags) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
assignFrom(REMatch other) |
(package private) void |
clear(int index)
Clears the current match and moves the offset to the new index.
|
Object |
clone() |
(package private) 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)
Deprecated.
Use getEndIndex(int) instead
|
int |
getSubStartIndex(int sub)
Deprecated.
Use getStartIndex(int) instead.
|
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.
|
private String matchedText
int eflags
int offset
int anchor
int index
int[] start
int[] end
REMatch(int subs, int anchor, int eflags)
void assignFrom(REMatch other)
void finish(CharIndexed text)
void clear(int 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. The initial position is zero.sub
- Subexpression indexpublic int getStartIndex(int sub)
-1
if
the subexpression does not exist. The initial position is zero.sub
- Subexpression indexpublic int getSubEndIndex(int sub)
-1
if
the subexpression does not exist. The initial position is zero.sub
- Subexpression indexpublic int getEndIndex(int sub)
-1
if
the subexpression does not exist. The initial position is zero.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.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses