BuiltIn.StrMatches Method

Applies to TestComplete 15.69, last modified on November 13, 2024
This method is obsolete. See the Remarks section below.

Description

Use this method to verify a string upon the specified regular expression.

Declaration

BuiltIn.StrMatches(ExpressionStr, Str)

ExpressionStr [in]    Required    String    
Str [in]    Required    String    
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

ExpressionStr

Specifies a regular expression pattern for the search. See the Regular Expressions Syntax topic for a list of available tokens.

Please note that the { } token used in this routine is employed to denote a match group. In other functions, it is used to indicate a number of symbol occurrences.

Str

Specifies a sought for string.

Result Value

True if a substring that matches the pattern was found and False otherwise.

Remarks

This method is obsolete. It is supported for backward compatibility only. To test a string against a regular expression pattern, use the aqString.StrMatches method.

Example

The following sample searches for the occurrences of "get" or "got" in three different sentences.

JavaScript, JScript

function StrMatchesSample()
{
  Log.Message(BuiltIn.StrMatches("g[eo]t", "John has got a good mark."))   // Returns True
  Log.Message(BuiltIn.StrMatches("g[eo]t", "Where did you get this?"))     // Returns True
  Log.Message(BuiltIn.StrMatches("g[eo]t", "There was a cow and a goat.")) // Returns False
}

Python

def StrMatchesSample():
  Log.Message(BuiltIn.StrMatches("g[eo]t", "John has got a good mark.")) # Returns True
  Log.Message(BuiltIn.StrMatches("g[eo]t", "Where did you get this?")) # Returns True
  Log.Message(BuiltIn.StrMatches("g[eo]t", "There was a cow and a goat.")) # Returns False

VBScript

Sub StrMatchesSample
  Log.Message(BuiltIn.StrMatches("g[eo]t", "John has got a good mark."))   ' Returns True
  Log.Message(BuiltIn.StrMatches("g[eo]t", "Where did you get this?"))     ' Returns True
  Log.Message(BuiltIn.StrMatches("g[eo]t", "There was a cow and a goat.")) ' Returns False
End Sub

DelphiScript

procedure StrMatchesSample;
begin 
  Log.Message(BuiltIn.StrMatches('g[eo]t', 'John has got a good mark.'));   // Returns True
  Log.Message(BuiltIn.StrMatches('g[eo]t', 'Where did you get this?'));     // Returns True
  Log.Message(BuiltIn.StrMatches('g[eo]t', 'There was a cow and a goat.')); // Returns False
end;

C++Script, C#Script

function StrMatchesSample()
{
  Log["Message"](BuiltIn["StrMatches"]("g[eo]t", "John has got a good mark."))   // Returns True
  Log["Message"](BuiltIn["StrMatches"]("g[eo]t", "Where did you get this?"))     // Returns True
  Log["Message"](BuiltIn["StrMatches"]("g[eo]t", "There was a cow and a goat.")) // Returns False
}

See Also

StrMatches Method
Find Method
Regular Expressions Syntax

Highlight search results