The following are methods for Matcher.
public Integer end()
Type: Integer
public Integer end(Integer groupIndex)
Type: Integer
public Boolean find()
Type: Boolean
This method starts at the beginning of this Matcher object's region, or, if a previous invocation of the method was successful and the Matcher object has not since been reset, at the first character not matched by the previous match.
If the match succeeds, more information can be obtained using the start, end, and group methods.
For more information, see Using Regions.
public Boolean find(Integer group)
Type: Boolean
If the match succeeds, more information can be obtained using the start, end, and group methods.
public String group()
Type: String
public String group(Integer groupIndex)
Type: String
Captured 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().
Note that some groups, such as (a*), match the empty string. This method returns the empty string when such a group successfully matches the empty string in the input.
public Integer groupCount()
Type: Integer
public Boolean hasAnchoringBounds()
Type: Boolean
If a Matcher object uses anchoring bounds, the boundaries of this Matcher object's region match start and end of line anchors such as ^ and $.
For more information, see Using Bounds.
public Boolean hasTransparentBounds()
Type: Boolean
For more information, see Using Bounds.
public Boolean hitEnd()
Type: Boolean
public Boolean lookingAt()
Type: Boolean
Like the matches method, this method always starts at the beginning of the region; unlike that method, it does not require the entire region be matched.
If the match succeeds, more information can be obtained using the start, end, and group methods.
See Using Regions.
public Boolean matches()
Type: Boolean
If the match succeeds, more information can be obtained using the start, end, and group methods.
See Using Regions.
public Pattern object pattern()
Type: System.Pattern
public Matcher object region(Integer start, Integer end)
Type: Matcher
This method first resets the Matcher object, then sets the region to start at the index specified by start and end at the index specified by end.
Depending on the transparency boundaries being used, certain constructs such as anchors may behave differently at or around the boundaries of the region.
See Using Regions and Using Bounds.
public Integer regionEnd()
Type: Integer
See Using Regions.
public Integer regionStart()
Type: Integer
See Using Regions.
public String replaceAll(String replacementString)
Type: String
This method first resets the Matcher object, then scans the input sequence looking for matches of the pattern. Characters that are not part of any match are appended directly to the result string; each match is replaced in the result by the replacement string. The replacement string may contain references to captured subsequences.
Note that backslashes (\) and dollar signs ($) in the replacement string may cause the results to be different than if the string was treated as a literal replacement string. Dollar signs may be treated as references to captured subsequences, and backslashes are used to escape literal characters in the replacement string.
Invoking this method changes this Matcher object's state. If the Matcher object is to be used in further matching operations it should first be reset.
Given the regular expression a*b, the input "aabxyzaabxyzabxyzb", and the replacement string "-", an invocation of this method on a Matcher object for that expression would yield the string "-xyz-xyz-xyz-".
public String replaceFirst(String replacementString)
Type: String
Note that backslashes (\) and dollar signs ($) in the replacement string may cause the results to be different than if the string was treated as a literal replacement string. Dollar signs may be treated as references to captured subsequences, and backslashes are used to escape literal characters in the replacement string.
Invoking this method changes this Matcher object's state. If the Matcher object is to be used in further matching operations it should first be reset.
Given the regular expression dog, the input "zzzdogzzzdogzzz", and the replacement string "cat", an invocation of this method on a Matcher object for that expression would return the string "zzzcatzzzdogzzz".
public Boolean requireEnd()
Type: Boolean
If this method returns true, and a match was found, then more input could cause the match to be lost.
If this method returns false and a match was found, then more input might change the match but the match won't be lost.
If a match was not found, then requireEnd has no meaning.
public Matcher object reset()
Type: Matcher
This method does not change whether the Matcher object uses anchoring bounds. You must explicitly use the useAnchoringBounds method to change the anchoring bounds.
For more information, see Using Bounds.
public Integer start()
Type: Integer
public Integer start(Integer groupIndex)
Type: Integer
public Matcher object useAnchoringBounds(Boolean anchoringBounds)
Type: Matcher
If a Matcher object uses anchoring bounds, the boundaries of this Matcher object's region match start and end of line anchors such as ^ and $.
For more information, see Using Bounds.
public Matcher object usePattern(Pattern pattern)
Type: Matcher
public Matcher object useTransparentBounds(Boolean transparentBounds)
Type: Matcher
For more information, see Using Bounds.