basic.match Relational Operator/BASIC Program

basic.match

Command basic.match Relational Operator/BASIC Program
Applicable release versions: AP, R83
Category BASIC Program (486)
Description tests a string and determines if it matches a pre-determined pattern of alphabetic, numeric, wild card, or literal characters.

The match operator compares a string value to a predefined pattern and evaluates to 1 (true) or 0 (false).

The "string.expression2" may be a composite of literals and/or match operators, appended to length specifications. During processing, the value must be the exact length of the length specifications parameter.

String operators:

na accept only "n" alphabetic characters.

mn accept only "m" numeric characters.

nx accept "n" wildcards (any character).

literal accepts any literal string enclosed in quotes.

The "n" parameter specifies the length of the match operator string. A length specification of 0 (zero) allows a length of zero or more of the following match operator. When combinations of matchstrings and literals are present, the entire matchstring must be enclosed in double quotes.

The character "n" tests only for decimal digits. "+", "-", and "." are NOT considered numeric.

The "iconv" function, using the pattern match ("p") processing code, provides similar functionality to the "match" or "matches" statement. The difference between the two, however, stems from the fact that "iconv" can perform multiple pattern matches at once, where the "match" or "matches" requires multiple statements.
Syntax string.expression1 match{es} string.expression2
Options
Example
if answer matches "3n" then print "ok"

This statement takes the "then" path if the answer is 3 characters.

if soc.sec.num matches "3n'-'2n'-'4n" then...

This checks that the value of the variable "soc.sec.num" has the 
pattern of 3 numbers, a "-" (dash), 2 numbers, a dash, and 4 numbers.

if not(response matches "0n") then...

The "then" clause is taken if "response" is NOT zero or 
more numbers.

if response = "0n,0n,0n" then...

This accepts any length of numbers, a comma, any length of numbers, a comma, 
and any length of numbers.
Purpose
Related basic.then/else.construct
basic.case
basic.then
basic.iconv
basic.if
basic.num
basic.alpha
pc.p
basic.pattern.matching
basic.matches
basic.ifr