|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Untamed:
Method Summary | |
int |
begin(int group)
Enabled: @param group The pattern subgroup. |
int |
beginOffset(int group)
Enabled: Returns an offset marking the beginning of the pattern match relative to the beginning of the input from which the match was extracted. |
int |
end(int group)
Enabled: @param group The pattern subgroup. |
int |
endOffset(int group)
Enabled: Returns an offset marking the end of the pattern match relative to the beginning of the input from which the match was extracted. |
String |
group(int group)
Enabled: Returns the contents of the parenthesized subgroups of a match, counting parentheses from left to right and starting from 1. |
int |
groups()
Enabled: @return The number of groups contained in the result. |
int |
length()
Enabled: A convenience method returning the length of the entire match. |
String |
toString()
Suppressed: Returns the same as group(0). |
Method Detail |
public int length()
group(int)
method to get
the string and then access its length() method as follows:
int length = -1; // Use -1 to indicate group doesn't exist MatchResult result; String subgroup; // Initialization of result omitted subgroup = result.group(1); if(subgroup != null) length = subgroup.length();
The length() method serves as a more a more efficient way to do:
length = result.group(0).length();
public int groups()
public String group(int group)
foo(\d+)
is used to extract a match
from the input abfoo123
, then group(0)
will return foo123
and group(1)
will return
123
. group(2)
will return
null
because there is only one subgroup in the original
pattern.
group
- The pattern subgroup to return.
public int begin(int group)
public int end(int group)
public int beginOffset(int group)
group
- The pattern subgroup.
public int endOffset(int group)
group
- The pattern subgroup.
public String toString()
toString
in class Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |