Skip to content

Matches Operator

See Also: Constrain Command, Contains Operator, Pos Function

Purpose

To return true from an expression in which the value of the first string matches the value or the ambiguous pattern specified by the value of the second string.

Syntax

( {host-string} matches {search-string} )

where

  • {host-string} is the string being parsed for {search-string}
  • {search-string} is the string being searched for inside {host-string}
  • {host-string} and {search-string} can be either a literal or a string variable
  • {search-string} can contain wildcard characters:
  • A question mark (?) may be used in {search-string} to permit a match with any character in {host-string}
  • An asterisk () may be used in {search-string}* to permit a match with 1 or more characters

What It Does

The matches operator compares the value of {search-string} with the value of {host-string} and returns 1 (True) if their values are the same and 0 (False) if they are not.

Any character given in {search-string} after an asterisk is of no effect -- a match will be reported regardless of what characters are in {search-string} after the position of the asterisk.

Examples

Example 1

If ((Clan.Name matches "Frazier") OR (Clan.Name matches "Fra?er")) Begin
    Send DoSomething
End

In this example, the procedure DoSomething is called when the value in the Name column of the Clan table is "Frazier" or "Fra" followed by any letter, followed by "er".

Example 2

If (Clan.Name matches "Fra*r") Begin
    Send DoSomething
End

In this example, the procedure DoSomething is called when the value in the Name column of the Clan table is "Fra" followed by any letters.

Example 3

If (Lowercase(Clan.Name) matches "frazier") Begin
    Send DoSomething
End

In this example, the procedure DoSomething is called whenever the value of the Name field of the Clan table is made up of the letters "frazier" regardless of their capitalization because the data is lowercase before the matches operator is executed.

Notes

  • Wildcard characters ( and ?) are evaluated simply as literals (asterisk and question mark, respectively) in {host-string}. They function as wildcards only in {search-string}*.