Skip to main content

Pattern Match Operator (?)

Pattern Match Operator (?)

The ObjectScript pattern match operator tests whether the characters in its left operand are correctly specified by the pattern in its right operand.

For example, the following tests if the string ssn contains a valid U.S. Social Security Number (3 digits, a hyphen, 2 digits, a hyphen, and 4 digits):

 SET ssn="123-45-6789"
 SET match = ssn ? 3N1"-"2N1"-"4N
 WRITE match

For pattern syntax and other details, see the Pattern Match (?) reference page.


ObjectScript also supports regular expressions, a pattern match syntax supported (with variants) by many software vendors. Regular expressions can be used with the $LOCATE and $MATCH functions, and with methods of the %Regex.MatcherOpens in a new tab class. For details, see the Regular Expressions reference page.

These pattern match systems are wholly separate and use different syntaxes with different patterns and flags.

FeedbackOpens in a new tab