API Overview API Index Package Overview Direct link to this page
JDK 1.6
  java.util.regex. Matcher View Source
Author(s)
Mike McCloskey
Mark Reinhold
JSR-51 Expert Group
Since
1.4
Version
1.64, 06/04/07
Serial
Hierarchy
 Object
      Matcher
Implements
 MatchResult
Subclasses
Description
publicfinal class Matcher
  An engine that performs match operations on a character sequence by interpreting a Pattern.
See also:   
Constructors
pack-private Matcher ()
No default constructor.
pack-private Matcher (Pattern parent, CharSequence text)
All matchers have the state used by Pattern during a match.
Methods
Hide/Show inherited methods
public Matcher appendReplacement (StringBuffer sb, String replacement)
  Implements a non-terminal append-and-replace step.
public StringBuffer appendTail (StringBuffer sb)
  Implements a terminal append-and-replace step.
pack-private char charAt (int i)
  Returns this Matcher's input character at index i.
public int end () [Specified in MatchResult]
  Returns the offset after the last character matched.
public int end (int group) [Specified in MatchResult]
  Returns the offset after the last character of the subsequence captured by the given group during the previous match operation.
public boolean find ()
  Attempts to find the next subsequence of the input sequence that matches the pattern.
public 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.
pack-private CharSequence getSubSequence (int beginIndex, int endIndex)
  Generates a String from this Matcher's input in the specified range.
pack-private int getTextLength ()
  Returns the end index of the text.
public String group () [Specified in MatchResult]
  Returns the input subsequence matched by the previous match.
public String group (int group) [Specified in MatchResult]
  Returns the input subsequence captured by the given group during the previous match operation.
public int groupCount () [Specified in MatchResult]
  Returns the number of capturing groups in this matcher's pattern.
public boolean hasAnchoringBounds ()
  Queries the anchoring of region bounds for this matcher.
public boolean hasTransparentBounds ()
  Queries the transparency of region bounds for this matcher.
public boolean hitEnd ()
  Returns true if the end of input was hit by the search engine in the last match operation performed by this matcher.
public boolean lookingAt ()
  Attempts to match the input sequence, starting at the beginning of the region, against the pattern.
pack-private boolean match (int from, int anchor)
  Initiates a search for an anchored match to a Pattern within the given bounds.
public boolean matches ()
  Attempts to match the entire region against the pattern.
public Pattern pattern ()
  Returns the pattern that is interpreted by this matcher.
publicstatic String quoteReplacement (String s)
  Returns a literal replacement String for the specified String.
public Matcher region (int start, int end)
  Sets the limits of this matcher's region.
public int regionEnd ()
  Reports the end index (exclusive) of this matcher's region.
public int regionStart ()
  Reports the start index of this matcher's region.
public String replaceAll (String replacement)
  Replaces every subsequence of the input sequence that matches the pattern with the given replacement string.
public String replaceFirst (String replacement)
  Replaces the first subsequence of the input sequence that matches the pattern with the given replacement string.
public boolean requireEnd ()
  Returns true if more input could change a positive match into a negative one.
public Matcher reset ()
  Resets this matcher.
public Matcher reset (CharSequence input)
  Resets this matcher with a new input sequence.
pack-private boolean search (int from)
  Initiates a search to find a Pattern within the given bounds.
public int start () [Specified in MatchResult]
  Returns the start index of the previous match.
public int start (int group) [Specified in MatchResult]
  Returns the start index of the subsequence captured by the given group during the previous match operation.
public MatchResult toMatchResult ()
  Returns the match state of this matcher as a MatchResult.
public String toString ()
  Returns the string representation of this matcher.
public Matcher useAnchoringBounds (boolean b)
  Sets the anchoring of region bounds for this matcher.
public Matcher usePattern (Pattern newPattern)
  Changes the Pattern that this Matcher uses to find matches with.
public Matcher useTransparentBounds (boolean b)
  Sets the transparency of region bounds for this matcher.
Fields
Hide/Show inherited fields
pack-private int acceptMode
pack-private boolean anchoringBounds
If anchoringBounds is true then the boundaries of this matcher's region match anchors such as ^ and $.
pack-privatefinalstatic int ENDANCHOR = "1"
  Matcher state used by the last node.
pack-private int first
  The range of string that last matched the pattern.
pack-private int from
  The range within the sequence that is to be matched.
pack-private int groups
  The storage used by groups.
pack-private boolean hitEnd
  Boolean indicating whether or not more input could change the results of the last match.
pack-private int last
  The range of string that last matched the pattern.
pack-private int lastAppendPosition
The index of the last position appended in a substitution.
pack-private int locals
  Storage used by nodes to tell what repetition they are on in a pattern, and where groups begin.
pack-private int lookbehindTo
Lookbehind uses this value to ensure that the subexpression match ends at the point where the lookbehind was encountered.
pack-privatefinalstatic int NOANCHOR = "0"
pack-private int oldLast
The end index of what matched in the last match operation.
pack-private Pattern parentPattern
The Pattern object that created this Matcher.
pack-private boolean requireEnd
  Boolean indicating whether or not more input could change a positive match into a negative one.
pack-private CharSequence text
The original string being matched.
pack-private int to
  The range within the sequence that is to be matched.
pack-private boolean transparentBounds
If transparentBounds is true then the boundaries of this matcher's region are transparent to lookahead, lookbehind, and boundary matching constructs that try to see beyond them.
Nested Classes
Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar