Name

RegExp.Test Method

Syntax

RegExp.Test(string)
string

Use: Required

Data Subtype: String

The string to be searched.

Return Value

A variant of subtype Boolean indicating whether a match was found.

Description

Performs a regular expression search against string and indicates whether a match was found

Rules at a Glance

  • Prior to calling the Test method, the search string should be defined by setting the Pattern property.

  • The method searches string using the RegExp object’s Pattern property.

  • The method returns True if the search succeeds and False otherwise.

Programming Tips & Gotchas

  • Since a search is successful if one match is found, you do not have to set the RegExp object’s Global property before calling the Test method.

  • You can use the method to determine whether a match exists before calling either the Execute or the Replace methods.

Get VBScript in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.