Skip to main content

Pattern Match Operator

The pattern match operator (?) is one of the most important and distinctive features of ObjectScript. You use this relational operator to compare a user's input string against a pattern, in order to verify the correctness of the string. A pattern specification is a series of one or more partial patterns using the following syntax:

<Quantity><Code>[<Quantity><Code>]...

In addition, you can enclose several partial patterns within parentheses, separated using commas, creating a list of alternatives. You precede the parenthesized section with a quantity, to account for optional or recurring sub-patterns within the specification.

Quantity Meaning - Code Meaning Code Meaning
3 Exactly 3   A Alphabetic (upper or lower) C Control characters
1.3 1 to 3   U Uppercase E Any character
.3 Up to 3   L Lowercase ANP Combination of codes
3. At least 3   N Numeric “anp” Literal string
. Any number including 0   P Punctuation    

Note that the pattern match codes in the table are the English language defaults. Caché locales allow you to specify alternate codes for different languages. Locales are beyond the scope of this tutorial.

FeedbackOpens in a new tab