THE Java™ Programming Language, Fourth Edition

(Jeff_L) #1
Attempts to match the entire input sequence against the pattern.

public booleanlookingAt()

Attempts to match the input sequence, starting at the beginning, against the
pattern. 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.

public booleanfind()

Attempts to find the next subsequence of the input sequence that matches the
pattern. This method starts at the beginning of the input sequence or, if a
previous invocation of find was successful and the matcher has not since
been reset, at the first character not matched by the previous match.

public booleanfind(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. If a
match is found, subsequent invocations of the find method will start at the
first character not matched by this match.

Once matching has commenced, the following methods allow the state of the matcher to be modified:


public Matcherreset()

Resets this matcher. This discards all state and resets the append position (see
below) to zero. The returned Matcher is the one on which the method was
invoked.

public Matcherreset(CharSequence input)

Resets this matcher to use a new input sequence. The returned Matcher is
the one on which the method was invoked.

public MatcherusePattern(Pattern pattern)

Changes the pattern used by this matcher to be pattern. Any group
information is discarded, but the input and append positions remain the same.

Once a match has been found, the following methods return more information about the match:


public intstart()

Returns the start index of the previous match.

public intend()

Returns the index of the last character matched, plus one.

public Stringgroup()

Returns the input subsequence matched by the previous match; in other
Free download pdf