Util.Match(String, String) 方法

定义

获取一个值,指示该测试是否与指定的模式匹配。

public:
 bool Match(System::String ^ bstrValue, System::String ^ bstrPattern);
public bool Match (string bstrValue, string bstrPattern);
abstract member Match : string * string -> bool
Public Function Match (bstrValue As String, bstrPattern As String) As Boolean

参数

bstrValue
String

将要对照模式进行测试的字符串。

bstrPattern
String

要使用的模式。

返回

如果指定的值与指定的模式相匹配,则返回 true,否则返回 false

示例

在以下示例中, 变量 isSsnValid 设置为一个值,该值指示存储在节点中的 my:SSN 值是否是合法的社会安全号码:

IXMLDOMNode ssnNode = thisXDocument.DOM.selectSingleNode(@"//my:SSN");
bool isSsnValid = thisXDocument.Util.<span class="label">Match</span>(ssnNode.text, @"\d\d\d-\d\d-\d\d\d\d");

注解

Match 方法可用于对照正则表达式来测试任何字符串。 正则表达式必须符合 W3C 的正则表达式 XML 架构规范 (http://www.w3.org/TR/xmlschema-2/#regexs).

注意:正则表达式的 XML 架构规范不同于 Perl 中的正则表达式。

重要说明:可以不受限制地访问此成员。

适用于