Modifier and Type | Method and Description |
---|---|
int |
end()
Returns the index of the last character matched, plus one.
|
int |
end(int group)
Returns the index of the last Symbol, plus one,
of the subsequence captured by the given group during the previous match operation.
|
boolean |
find()
Attempts to find the next subsequence of the input sequence that matches the pattern.
|
boolean |
find(int start)
Resets this matcher and then attempts to find the next subsequence
of the input sequence that matches the pattern, starting at the specified index.
|
SymbolList |
group()
Returns the input subsequence matched by the previous match.
|
SymbolList |
group(int group)
Returns the input subsequence captured by the given group during the previous match operation.
|
int |
groupCount()
Returns the number of capturing groups in this matcher's pattern.
|
boolean |
lookingAt()
Attempts to match the input SymbolList, starting at the beginning, against the pattern.
|
boolean |
matches()
Attempts to match the entire input sequence against the pattern.
|
Pattern |
pattern()
Returns the Pattern object that compiled this Matcher.
|
Matcher |
reset()
Resets this matcher.
|
Matcher |
reset(SymbolList sl)
Resets this matcher with a new input SymbolList.
|
int |
start()
Returns the start index of the previous match.
|
int |
start(int group)
Returns the start index of the subsequence captured by the given group during the previous match operation.
|
public int end()
public int end(int group) throws IndexOutOfBoundsException
Capturing groups are indexed from left to right, starting at one. Group zero denotes the entire pattern, so the expression m.end(0) is equivalent to m.end().
group
- The index of a capturing group in this matcher's pattern.IndexOutOfBoundsException
public boolean find()
This method starts at the beginning of the input sequence or, if a previous invocation of the method was successful and the matcher has not since been reset, at the first Symbol not matched by the previous match. If the match succeeds then more information can be obtained via the start, end, and group methods.
public boolean find(int start) throws IndexOutOfBoundsException
If the match succeeds then more information can be obtained via the start, end, and group methods, and subsequent invocations of the find() method will start at the first Symbol not matched by this match.
IndexOutOfBoundsException
public SymbolList group()
For a matcher m with input sequence s, the expressions m.group() and s.substring(m.start(), m.end()) are equivalent. Note that some patterns, for example a*, match the empty SymbolList. This method will return the empty string when the pattern successfully matches the empty string in the input.
public SymbolList group(int group) throws IndexOutOfBoundsException
For a matcher m, input sequence s, and group index g, the expressions m.group(g) and s.substring(m.start(g), m.end(g)) are equivalent. Capturing groups are indexed from left to right, starting at one. Group zero denotes the entire pattern, so the expression m.group(0) is equivalent to m.group(). If the match was successful but the group specified failed to match any part of the input sequence, then null is returned. Note that some groups, for example (a*), match the empty string. This method will return the empty string when such a group successfully matches the emtpy string in the input.
IndexOutOfBoundsException
public int groupCount()
Any non-negative integer smaller than the value returned by this method is guaranteed to be a valid group index for this matcher.
public boolean lookingAt()
Like the matches method, this method always starts at the beginning of the input sequence; unlike that method, it does not require that the entire input sequence be matched. If the match succeeds then more information can be obtained via the start, end, and group methods.
public boolean matches()
If the match succeeds then more information can be obtained via the start, end, and group methods.
public Matcher reset()
Resetting a matcher discards all of its explicit state information and sets its append position to zero.
public Matcher reset(SymbolList sl)
Resetting a matcher discards all of its explicit state information and sets its append position to zero.
public int start()
public int start(int group)
Capturing groups are indexed from left to right, starting at one. Group zero denotes the entire pattern, so the expression m.start(0) is equivalent to m.start().
group
- The index of a capturing group in this matcher's pattern.Copyright © 2014 BioJava. All rights reserved.