VBS tutorial: method test method

Time:2021-11-25

Test method

Performs a regular expression search on the specified string and returns a Boolean value indicating whether a matching pattern was found.

object.Test(string)

parameter

object

Required. Always the name of a regexp object.

string

Required. The text string to perform the regular expression search.

explain

The actual pattern of regular expression search is set through the pattern property of the regexp object. The regexp.global property has no effect on the test method.

If a matching pattern is found, the test method returns true; Otherwise, false is returned.

The following code illustrates the use of the test method.

Function RegExpTest(patrn, strng)  Dim regEx, retVal             '  Create variables. Set regEx = New RegExp          '  Establish regular expressions. regEx.Pattern = patrn          '  Set the mode. regEx.IgnoreCase = False          '  Sets whether the is case sensitive. retVal = regEx.Test(strng)          '  Perform a search test. If retval then regexptest = "one or more matches found." else regexptest = "no matches found." end IfEnd functionmsgbox (regexptest ("is.", "is1 is2 is3 is4"))

Recommended Today

Seven solutions for distributed transactions

1、 What is distributed transaction Distributed transaction means that transaction participants, transaction supporting servers, resource servers and transaction managers are located on different nodes of different distributed systems. A large operation is completed by more than n small operations. These small operations are distributed on different services. For these operations, either all of them are […]