Matcher Class

Definition

An engine that performs match operations on a java.

[Android.Runtime.Register("java/util/regex/Matcher", DoNotGenerateAcw=true)]
public sealed class Matcher : Java.Lang.Object, IDisposable, Java.Interop.IJavaPeerable, Java.Util.Regex.IMatchResult
[<Android.Runtime.Register("java/util/regex/Matcher", DoNotGenerateAcw=true)>]
type Matcher = class
    inherit Object
    interface IMatchResult
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
Matcher
Attributes
Implements

Remarks

An engine that performs match operations on a java.lang.CharSequence character sequence by interpreting a Pattern.

A matcher is created from a pattern by invoking the pattern's Pattern#matcher matcher method. Once created, a matcher can be used to perform three different kinds of match operations:

<ul>

<li>

The #matches matches method attempts to match the entire input sequence against the pattern.

</li>

<li>

The #lookingAt lookingAt method attempts to match the input sequence, starting at the beginning, against the pattern.

</li>

<li>

The #find find method scans the input sequence looking for the next subsequence that matches the pattern.

</li>

</ul>

Each of these methods returns a boolean indicating success or failure. More information about a successful match can be obtained by querying the state of the matcher.

A matcher finds matches in a subset of its input called the region. By default, the region contains all of the matcher's input. The region can be modified via the #region(int, int) region method and queried via the #regionStart() regionStart and #regionEnd() regionEnd methods. The way that the region boundaries interact with some pattern constructs can be changed. See #useAnchoringBounds(boolean) useAnchoringBounds and #useTransparentBounds(boolean) useTransparentBounds for more details.

This class also defines methods for replacing matched subsequences with new strings whose contents can, if desired, be computed from the match result. The #appendReplacement appendReplacement and #appendTail appendTail methods can be used in tandem in order to collect the result into an existing string buffer or string builder. Alternatively, the more convenient #replaceAll replaceAll method can be used to create a string in which every matching subsequence in the input sequence is replaced.

The explicit state of a matcher includes the start and end indices of the most recent successful match. It also includes the start and end indices of the input subsequence captured by each capturing group in the pattern as well as a total count of such subsequences. As a convenience, methods are also provided for returning these captured subsequences in string form.

The explicit state of a matcher is initially undefined; attempting to query any part of it before a successful match will cause an IllegalStateException to be thrown. The explicit state of a matcher is recomputed by every match operation.

The implicit state of a matcher includes the input character sequence as well as the append position, which is initially zero and is updated by the #appendReplacement appendReplacement method.

A matcher may be reset explicitly by invoking its #reset() method or, if a new input sequence is desired, its #reset(java.lang.CharSequence) reset(CharSequence) method. Resetting a matcher discards its explicit state information and sets the append position to zero.

Instances of this class are not safe for use by multiple concurrent threads.

Added in 1.4.

Java documentation for java.util.regex.Matcher.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
HasAnchoringBounds

Queries the anchoring of region bounds for this matcher.

HasTransparentBounds

Queries the transparency of region bounds for this matcher.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)

Methods

AppendReplacement(StringBuffer, String)

Implements a non-terminal append-and-replace step.

AppendReplacement(StringBuilder, String)

Implements a non-terminal append-and-replace step.

AppendTail(StringBuffer)

Implements a terminal append-and-replace step.

AppendTail(StringBuilder)

Implements a terminal append-and-replace step.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
End()

Returns the offset after the last character matched.

End(Int32)

Returns the offset after the last character of the subsequence captured by the given group during the previous match operation.

End(String)

Returns the offset after the last character of the subsequence captured by the given named-capturing group during the previous match operation.

Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
Find()

Attempts to find the next subsequence of the input sequence that matches the pattern.

Find(Int32)

Resets this matcher and then attempts to find the next subsequence of the input sequence that matches the pattern, starting at the specified index.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
Group()

Returns the input subsequence matched by the previous match.

Group(Int32)

Returns the input subsequence captured by the given group during the previous match operation.

Group(String)

Returns the input subsequence captured by the given named-capturing group during the previous match operation.

GroupCount()

Returns the number of capturing groups in this matcher's pattern.

HitEnd()

Returns true if the end of input was hit by the search engine in the last match operation performed by this matcher.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
LookingAt()

Attempts to match the input sequence, starting at the beginning of the region, against the pattern.

Matches()

Attempts to match the entire region against the pattern.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
Pattern()

Returns the pattern that is interpreted by this matcher.

QuoteReplacement(String)

Returns a literal replacement String for the specified String.

Region(Int32, Int32)

Sets the limits of this matcher's region.

RegionEnd()

Reports the end index (exclusive) of this matcher's region.

RegionStart()

Reports the start index of this matcher's region.

ReplaceAll(IFunction)

Replaces every subsequence of the input sequence that matches the pattern with the result of applying the given replacer function to the match result of this matcher corresponding to that subsequence.

ReplaceAll(String)

Replaces every subsequence of the input sequence that matches the pattern with the given replacement string.

ReplaceFirst(IFunction)

Replaces the first subsequence of the input sequence that matches the pattern with the result of applying the given replacer function to the match result of this matcher corresponding to that subsequence.

ReplaceFirst(String)

Replaces the first subsequence of the input sequence that matches the pattern with the given replacement string.

RequireEnd()

Returns true if more input could change a positive match into a negative one.

Reset()

Resets this matcher.

Reset(ICharSequence)

Resets this matcher with a new input sequence.

Reset(String)

Resets this matcher with a new input sequence.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
Start()

Returns the start index of the previous match.

Start(Int32)

Returns the start index of the subsequence captured by the given group during the previous match operation.

Start(String)

Returns the start index of the subsequence captured by the given named-capturing group during the previous match operation.

ToArray<T>() (Inherited from Object)
ToMatchResult()

Returns the match state of this matcher as a MatchResult.

ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
UseAnchoringBounds(Boolean)

Sets the anchoring of region bounds for this matcher.

UsePattern(Pattern)

Changes the Pattern that this Matcher uses to find matches with.

UseTransparentBounds(Boolean)

Sets the transparency of region bounds for this matcher.

Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to