Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Match Method
Collapse the table of content
Expand the table of content

Util.Match Method

Office 2010

Gets a value that indicates whether the test matches the specified pattern.

Namespace:  Microsoft.Office.Interop.InfoPath
Assembly:  Microsoft.Office.Interop.InfoPath (in Microsoft.Office.Interop.InfoPath.dll)

bool Match(
	string bstrValue,
	string bstrPattern


Type: System.String

The string to test against the pattern.

Type: System.String

The pattern to use.

Return Value

Type: System.Boolean
true if the specified value matches the specified pattern; otherwise false.

The Match method can be used to test any string against a regular expression. The regular expression must conform to the W3C's XML Schema specification for regular expressions (http://www.w3.org/TR/xmlschema-2/#regexs).


The XML Schema specification for regular expressions is different from regular expressions in Perl.

In the following example, the variable isSsnValid is set to a value that indicates whether or not the value stored in the my:SSN node is a legal Social Security Number:

IXMLDOMNode ssnNode = thisXDocument.DOM.selectSingleNode(@"//my:SSN");
bool isSsnValid = thisXDocument.Util.Match(ssnNode.text, @"\d\d\d-\d\d-\d\d\d\d");
© 2015 Microsoft