Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

pattern

1990 Version of ANSI Standard

2.3.3 Pattern match

The pattern match operator ? tests the form of the string which is its left-hand operand. S ? P is true if and only if S is a member of the class of strings specified by the pattern P.

A pattern is a concatenated list of pattern atoms.

    pattern::=

patatom ...
@ expratom V pattern


See 2.2 for the definition of expratom. See section 1 for the definition of V.

Assume that pattern has n patatoms. S ? pattern is true if and only if there exists a partition of S into n substrings

   S = S1 S2 ... Sn

such that there is a one-to-one order-preserving correspondence between the Si and the pattern atoms, and each Si satisfies its respective pattern atom. Note that some of the Si may be empty.

Each pattern atom consists of a repeat count repcount, followed by either a pattern code patcode or a string literal strlit. A substring Si of S satisfies a pattern atom if it, in turn, can be decomposed into a number of concatenated substrings, each of which satisfies the associated patcode or strlit.

    patatom::= repcount

patcode
strlit


See 2.2.5 for the definition of strlit.

    repcount::=

intlit
[ intlit1 ] . [ intlit2 ]


See 2.2.3 for the definition of intlit.

    patcode::=






C
N
P
A
L
U
E







...

Patcodes differing only in the use of corresponding upper and lower case letters are equivalent. Each patcode is satisfied by any single character in the union of the classes of characters represented, each class denoted by its own patcode letter, as follows.

C 33 ASCII control characters, including DEL
N 10 ASCII numeric characters
P 33 ASCII punctuation characters, including SP
A 52 ASCII alphabetic characters
L 26 ASCII lower-case alphabetic characters
U 26 ASCII upper-case alphabetic characters
E Everything (the entire set of ASCII characters)

All other unused patcode letters for class names are reserved.

Each strlit is satisfied by, and only by, the value of strlit.

If repcount has the form of an indefinite multiplier ".", patatom is satisfied by a concatenation of any number of Si (including none), each of which meets the specification of patatom.

If repcount has the form of a single intlit, patatom is satisfied by a concatenation exactly intlit Si, each of which meets the specification of patatom. In particular, if the value of intlit is zero, the corresponding Si is empty.

If repcount has the form of a range, intlit1.intlit2, the first intlit gives the lower bound, and the second intlit the upper bound. It is erroneous if the upper bound is less than the lower bound. If the lower bound is omitted, so that the range has the form .intlit2 , the lower bound is taken to be zero. If the upper bound is omitted, so that the range has the form intlit1. , the upper bound is taken to be indefinite; that is, the range is at least intlit1 occurrences. Then patatom is satisfied by the concatenation of a number of Si, each of which meets the specification of patatom, where the number must be within the expressed or implied bounds of the specified range, inclusive.

The dual operator '? is defined by:

   A '? B = '(A ? B)

Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

Copyright © Standard Documents; 1977-2024 MUMPS Development Committee;
Copyright © Examples: 1995-2024 Ed de Moel;
Copyright © Annotations: 2003-2008 Jacquard Systems Research
Copyright © Annotations: 2008-2024 Ed de Moel.

This page most recently updated on 15-Nov-2023, 13:19:37.

For comments, contact Ed de Moel (demoel@jacquardsystems.com)