Util.Match(String, String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a value that indicates whether the test matches the specified pattern.
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
Parameters
- bstrValue
- String
The string to test against the pattern.
- bstrPattern
- String
The pattern to use.
Returns
true if the specified value matches the specified pattern; otherwise false.
Examples
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.<span class="label">Match</span>(ssnNode.text, @"\d\d\d-\d\d-\d\d\d\d");
Remarks
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).
Note: The XML Schema specification for regular expressions is different from regular expressions in Perl.