java.util.regex
public final class Matcher extends Object implements MatchResult
Since: 1.4
Method Summary | |
---|---|
Matcher | appendReplacement(StringBuffer sb, String replacement) |
StringBuffer | appendTail(StringBuffer sb) |
int | end() |
int | end(int group) |
boolean | find() |
boolean | find(int start) |
String | group() |
String | group(int group) |
int | groupCount() |
boolean | hasAnchoringBounds()
Returns true if the matcher will honour the use of
the anchoring bounds: {@code ^}, {@code \A}, {@code \Z},
{@code \z} and {@code $}. |
boolean | hasTransparentBounds()
Returns true if the bounds of the region marked by
regionStart and regionEnd are
transparent. |
boolean | hitEnd() |
boolean | lookingAt() |
boolean | matches()
Attempts to match the entire input sequence against the pattern.
|
Pattern | pattern()
Returns the Pattern that is interpreted by this Matcher |
Matcher | region(int start, int end) Defines the region of the input on which to match. |
int | regionEnd()
The end of the region on which to perform matches (exclusive).
|
int | regionStart()
The start of the region on which to perform matches (inclusive).
|
String | replaceAll(String replacement) |
String | replaceFirst(String replacement) |
Matcher | reset()
Resets the internal state of the matcher, including
resetting the region to its default state of encompassing
the whole input. |
Matcher | reset(CharSequence input)
Resets the internal state of the matcher, including
resetting the region to its default state of encompassing
the whole input. |
int | start() |
int | start(int group) |
MatchResult | toMatchResult()
Returns a read-only snapshot of the current state of
the Matcher as a MatchResult. |
String | toString() |
Matcher | useAnchoringBounds(boolean useAnchors)
Enables or disables the use of the anchoring bounds:
{@code ^}, {@code \A}, {@code \Z}, {@code \z} and
{@code $}. |
Matcher | useTransparentBounds(boolean transparent)
Sets the transparency of the bounds of the region
marked by regionStart and regionEnd.
|
Parameters: sb The target string buffer replacement The replacement string
Throws: IllegalStateException If no match has yet been attempted, or if the previous match operation failed IndexOutOfBoundsException If the replacement string refers to a capturing group that does not exist in the pattern
Parameters: sb The target string buffer
Throws: IllegalStateException If no match has yet been attempted, or if the previous match operation failed
Parameters: group The index of a capturing group in this matcher's pattern
Throws: IllegalStateException If no match has yet been attempted, or if the previous match operation failed IndexOutOfBoundsException If the replacement string refers to a capturing group that does not exist in the pattern
Parameters: start The index to start the new pattern matching
Throws: IndexOutOfBoundsException If the replacement string refers to a capturing group that does not exist in the pattern
Throws: IllegalStateException If no match has yet been attempted, or if the previous match operation failed
Parameters: group The index of a capturing group in this matcher's pattern
Throws: IllegalStateException If no match has yet been attempted, or if the previous match operation failed IndexOutOfBoundsException If the replacement string refers to a capturing group that does not exist in the pattern
Returns: true if the matcher will attempt to match the anchoring bounds.
Since: 1.5
See Also: Matcher hasTransparentBounds
Returns: true if the bounds of the matching region are transparent.
Since: 1.5
See Also: Matcher Matcher regionStart regionEnd
Returns: True if and only if the matcher hit the end of input.
Since: 1.5
Defines the region of the input on which to match. By default, the Matcher attempts to match the whole string (from 0 to the length of the input), but a region between {@code start} (inclusive) and {@code end} (exclusive) on which to match may instead be defined using this method.
The behaviour of region matching is further affected by the use of transparent or opaque bounds (see Matcher) and whether or not anchors ({@code ^} and {@code $}) are in use (see Matcher). With transparent bounds, the matcher is aware of input outside the bounds set by this method, whereas, with opaque bounds (the default) only the input within the bounds is used. The use of anchors are affected by this setting; with transparent bounds, anchors will match the beginning of the real input, while with opaque bounds they match the beginning of the region. Matcher can be used to turn on or off the matching of anchors.
Parameters: start the start of the region (inclusive). end the end of the region (exclusive).
Returns: a reference to this matcher.
Throws: IndexOutOfBoundsException if either {@code start} or {@code end} are less than zero, if either {@code start} or {@code end} are greater than the length of the input, or if {@code start} is greater than {@code end}.
Since: 1.5
See Also: regionStart regionEnd hasTransparentBounds Matcher hasAnchoringBounds Matcher
Returns: the end index of the region.
Since: 1.5
See Also: Matcher regionStart
Returns: the start index of the region.
Since: 1.5
See Also:
#see #regionEnd()
Parameters: replacement The replacement string
Parameters: replacement The replacement string
Returns: a reference to this matcher.
See Also: regionStart regionEnd hasTransparentBounds hasAnchoringBounds
Parameters: input The new input character sequence.
Returns: a reference to this matcher.
See Also: regionStart regionEnd hasTransparentBounds hasAnchoringBounds
Returns: the index of a capturing group in this matcher's pattern
Throws: IllegalStateException If no match has yet been attempted, or if the previous match operation failed
Parameters: group The index of a capturing group in this matcher's pattern
Throws: IllegalStateException If no match has yet been attempted, or if the previous match operation failed IndexOutOfBoundsException If the replacement string refers to a capturing group that does not exist in the pattern
Returns: a MatchResult instance representing the current state of the Matcher.
Returns: A string expression of this matcher.
Parameters: useAnchors true if anchoring bounds should be used.
Returns: a reference to this matcher.
Since: 1.5
See Also: hasAnchoringBounds
Parameters: transparent true if the bounds should be transparent.
Returns: a reference to this matcher.
Since: 1.5
See Also: hasTransparentBounds Matcher regionStart regionEnd