語言

String.Matches(String) 方法

定義

判斷此字串是否符合給定的正則表達式。

[Android.Runtime.Register("matches", "(Ljava/lang/String;)Z", "")]
public bool Matches(string regex);
[<Android.Runtime.Register("matches", "(Ljava/lang/String;)Z", "")>]
member this.Matches : string -> bool

參數

regex
String

此字串所對應的正則表達式

傳回

true 當且僅當該字串與給定的正則表達式相符

屬性

例外狀況

如果 regularExpression == null

備註

判斷此字串是否符合給定的正則表達式。

str.matches(regex) 形式呼叫此方法,結果與表達式完全相同

<引用>java.util.regex.Patternjava.util.regex.Pattern#matches(String,CharSequence) matches(<i>regex</i>, <i>str</i>)</區塊引用>

在 1.4 版本加入。

Java 文件 java.lang.String.matches(java.lang.String)

此頁面的部分是根據 Android 開放原始碼專案所建立和共用的工作進行修改,並根據 Creative Commons 2.5 屬性授權中所述的詞彙使用。

適用於