Pattern.Matches Method

Definition

Overloads

Matches(String, ICharSequence)

Compiles the given regular expression and attempts to match the given input against it.

Matches(String, String)

Compiles the given regular expression and attempts to match the given input against it.

Matches(String, ICharSequence)

Compiles the given regular expression and attempts to match the given input against it.

[Android.Runtime.Register("matches", "(Ljava/lang/String;Ljava/lang/CharSequence;)Z", "")]
public static bool Matches (string regex, Java.Lang.ICharSequence input);
[<Android.Runtime.Register("matches", "(Ljava/lang/String;Ljava/lang/CharSequence;)Z", "")>]
static member Matches : string * Java.Lang.ICharSequence -> bool

Parameters

regex
String

The expression to be compiled

input
ICharSequence

The character sequence to be matched

Returns

whether or not the regular expression matches on the input

Attributes

Remarks

Compiles the given regular expression and attempts to match the given input against it.

An invocation of this convenience method of the form

<blockquote>

Pattern.matches(regex, input);

</blockquote>

behaves in exactly the same way as the expression

<blockquote>

Pattern.compile(regex).matcher(input).matches()

</blockquote>

If a pattern is to be used multiple times, compiling it once and reusing it will be more efficient than invoking this method each time.

Java documentation for java.util.regex.Pattern.matches(java.lang.String, java.lang.CharSequence).

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.

See also

  • <xref:Java.Util.Regex.Pattern.Compile(System.String%2c+Java.Util.Regex.RegexOptions)>
  • Matches()

Applies to

Matches(String, String)

Compiles the given regular expression and attempts to match the given input against it.

public static bool Matches (string regex, string input);
static member Matches : string * string -> bool

Parameters

regex
String

The expression to be compiled

input
String

The character sequence to be matched

Returns

whether or not the regular expression matches on the input

Remarks

Compiles the given regular expression and attempts to match the given input against it.

An invocation of this convenience method of the form

<blockquote>

Pattern.matches(regex, input);

</blockquote>

behaves in exactly the same way as the expression

<blockquote>

Pattern.compile(regex).matcher(input).matches()

</blockquote>

If a pattern is to be used multiple times, compiling it once and reusing it will be more efficient than invoking this method each time.

Java documentation for java.util.regex.Pattern.matches(java.lang.String, java.lang.CharSequence).

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.

Applies to