MATCHES


The MATCH or MATCHES function allows pattern matching to be applied to an expression.

 

COMMAND SYNTAX

expression1 MATCHES expression2

 

SYNTAX ELEMENTS

expression1 may evaluate to any type. expression2 should evaluate to a valid pattern matching string as described below. expression1 is then matched to the pattern supplied and a value of Boolean TRUE is returned if the pattern is matched. A value of Boolean FALSE is returned if the pattern is not matched.

expression2 can contain any number of patterns to match separated by value marks. The value mark implies a logical OR of the specified patterns and the match will evaluate to Boolean TRUE if expression1 matches any of the specified patterns.

 

NOTES

Pattern matching strings are constructed from the rule table shown below. When reading the table n refers to any integer number.

Pattern Explanation
nN this construct matches a sequence of n digits
nA this construct matches a sequence of n alpha characters
nC this construct matches a sequence of n alpha characters or digits
nX this construct matches a sequence of any characters
"string" This construct matches the character sequence string exactly.

The pattern will be applied to all characters in expression1 and it must match all characters in the expression to evaluate as Boolean TRUE.

The integer value n can be specified as 0. This will cause the pattern to match any number of characters of the specified type.

 

EXAMPLES

IF Var MATCHES "0N" THEN CRT "A match!"

matches if all characters in Var are numeric or Var is a null string.

 

IF Var MATCHES "0N'.'2N"...

matches if Var contains any number of numerics followed by the . character followed by 2 numeric characters. e.g. 345.65 or 9.99

 

Pattern = "4X':'6N';'2A"
Matched = Serno MATCHES Pattern

matches if the variable Serno consists of a string of 4 arbitrary characters followed by the ":" character then 6 numerics then the ";" character and then 2 alphabetic characters. e.g. 1.2.:123456;AB or 17st:456789;FB


jBC