Android Guides | Samples

Java.Lang.String.Matches Method

Tests whether this string matches the given regularExpression.

Syntax

[Android.Runtime.Register("matches", "(Ljava/lang/String;)Z", "")]
public Boolean Matches (String expr)

Parameters

regularExpression

Exceptions

TypeReason
!:NoType:if the syntax of the supplied regular expression is not valid.
NullPointerExceptionif regularExpression == null

Remarks

Tests whether this string matches the given regularExpression. This method returns true only if the regular expression matches the entire input string. A common mistake is to assume that this method behaves like String.Contains(ICharSequence); if you want to match anywhere within the input string, you need to add .* to the beginning and end of your regular expression. See Pattern.Matches(String,ICharSequence).

If the same regular expression is to be used for multiple operations, it may be more efficient to reuse a compiled Pattern.

[Android Documentation]

Requirements

Namespace: Java.Lang
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1