|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.code.regexp.Matcher
public class Matcher
An engine that performs match operations on a character sequence by
interpreting a Pattern
. This is a wrapper for Matcher
.
Method Summary | |
---|---|
Matcher |
appendReplacement(StringBuffer sb,
String replacement)
Implements a non-terminal append-and-replace step. |
StringBuffer |
appendTail(StringBuffer sb)
Implements a terminal append-and-replace step. |
int |
end()
Returns the offset after the last character matched. |
int |
end(int group)
Returns the offset after the last character of the subsequence captured by the given group during the previous match operation. |
int |
end(String groupName)
Returns the offset after the last character of the subsequence captured by the given named group during the previous match operation. |
boolean |
equals(Object obj)
|
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. |
String |
group()
Returns the input subsequence matched by the previous match. |
String |
group(int group)
Returns the input subsequence captured by the given group during the previous match operation. |
String |
group(String groupName)
Returns the input subsequence captured by the named group during the previous match operation. |
int |
groupCount()
Returns the number of capturing groups in this matcher's pattern. |
boolean |
hasAnchoringBounds()
Queries the anchoring of region bounds for this matcher. |
int |
hashCode()
|
boolean |
hasTransparentBounds()
Queries the transparency of region bounds for this matcher. |
boolean |
hitEnd()
Returns true if the end of input was hit by the search engine in the last match operation performed by this matcher. |
boolean |
lookingAt()
Attempts to match the input sequence, starting at the beginning of the region, against the pattern. |
boolean |
matches()
Attempts to match the entire region against the pattern. |
Map<String,String> |
namedGroups()
Finds all named groups that exist in the input string. |
Pattern |
namedPattern()
Returns the named pattern that is interpreted by this matcher. |
List<String> |
orderedGroups()
Gets a list of the matches in the order in which they occur in a matching input string |
Matcher |
region(int start,
int end)
Sets the limits of this matcher's region. |
int |
regionEnd()
Reports the end index (exclusive) of this matcher's region. |
int |
regionStart()
Reports the start index of this matcher's region. |
String |
replaceAll(String replacement)
Replaces every subsequence of the input sequence that matches the pattern with the given replacement string. |
String |
replaceFirst(String replacement)
Replaces the first subsequence of the input sequence that matches the pattern with the given replacement string. |
boolean |
requireEnd()
Returns true if more input could change a positive match into a negative one. |
Matcher |
reset()
Resets this matcher |
Matcher |
reset(CharSequence input)
Resets this matcher with a new input sequence |
Pattern |
standardPattern()
Returns the pattern that is interpreted by this matcher. |
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. |
int |
start(String groupName)
Returns the start index of the subsequence captured by the given named group during the previous match operation. |
MatchResult |
toMatchResult()
Returns the match state of this matcher as a NamedMatchResult. |
String |
toString()
|
Matcher |
useAnchoringBounds(boolean b)
Sets the anchoring of region bounds for this matcher. |
Matcher |
usePattern(Pattern newPattern)
Changes the Pattern that this Matcher uses to find matches with |
Matcher |
useTransparentBounds(boolean b)
Sets the transparency of region bounds for this matcher. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public Pattern standardPattern()
public Pattern namedPattern()
public Matcher usePattern(Pattern newPattern)
newPattern
- the new pattern
public Matcher reset()
public Matcher reset(CharSequence input)
Resetting a matcher discards all of its explicit state information and sets its append position to zero. The matcher's region is set to the default region, which is its entire character sequence. The anchoring and transparency of this matcher's region boundaries are unaffected
input
- The new input character sequence
public boolean matches()
If the match succeeds then more information can be obtained via the start, end, and group methods.
true
if, and only if, the entire region sequence
matches this matcher's patternpublic MatchResult toMatchResult()
public boolean find()
This method starts at the beginning of this matcher's region, or, if a previous invocation of the method was successful and the matcher has not since been reset, at the first character 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)
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 character not matched by this match.
start
- the starting index
true
if, and only if, a subsequence of the input
sequence starting at the given index matches this matcher's pattern
IndexOutOfBoundsException
- If start is less than zero or if start
is greater than the length of the input sequence.public boolean lookingAt()
Like the matches method, this method always starts at the beginning of the region; unlike that method, it does not require that the entire region be matched.
If the match succeeds then more information can be obtained via the start, end, and group methods.
true
if, and only if, a prefix of the input sequence
matches this matcher's patternpublic Matcher appendReplacement(StringBuffer sb, String replacement)
sb
- The target string bufferreplacement
- The replacement string
public StringBuffer appendTail(StringBuffer sb)
sb
- The target string buffer
public String group()
group
in interface MatchResult
public String group(int group)
group
in interface MatchResult
group
- The index of a capturing group in this matcher's pattern
IllegalStateException
- If no match has yet been attempted, or
if the previous match operation failedpublic int groupCount()
groupCount
in interface MatchResult
public List<String> orderedGroups()
public String group(String groupName)
groupName
- name of the capture group
IndexOutOfBoundsException
- if group name not foundpublic Map<String,String> namedGroups()
public int start()
start
in interface MatchResult
public int start(int group)
start
in interface MatchResult
group
- the index of the capture group
public int start(String groupName)
groupName
- the name of the capture group
public int end()
end
in interface MatchResult
public int end(int group)
end
in interface MatchResult
group
- the index of the capture group
public int end(String groupName)
group
- the name of the capture group
public Matcher region(int start, int end)
start
- The index to start searching at (inclusive)end
- The index to end searching at (exclusive)
public int regionEnd()
public int regionStart()
public boolean hitEnd()
public boolean requireEnd()
public boolean hasAnchoringBounds()
public boolean hasTransparentBounds()
public String replaceAll(String replacement)
replacement
- The replacement string
public String replaceFirst(String replacement)
replacement
- The replacement string
public Matcher useAnchoringBounds(boolean b)
b
- a boolean indicating whether or not to use anchoring bounds.
public Matcher useTransparentBounds(boolean b)
b
- a boolean indicating whether to use opaque or transparent regions
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |