z/OS TSO/E REXX Reference
|
Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Templates containing positional (numeric) patterns z/OS TSO/E REXX Reference SA32-0972-00 |
|
|
A positional pattern is a number that identifies the character position at which to split data in the source string. The number must be a whole number. An absolute positional pattern is
The number specifies the absolute character position at which to split the source string. Here is a template with absolute positional patterns:
The numbers 11 and 21 are absolute
positional patterns. The number 11 refers to the
11th position in the input string, 21 to the 21st
position. This template:
Positional patterns are probably most useful for working with a file of records, such as: ![]() The following example uses this record structure.
The source string is first split at character position 11 and at position 21. The language processor assigns characters 1 to 10 into lastname, characters 11 to 20 into firstname, and characters 21 to 40 into pseudonym. The template could have been:
instead of
Specifying the 1 is optional. Optionally, you can put an equal sign before a number in a
template. An equal sign is the same as no sign before a number in
a template. The number refers to a particular character position in
the source string. These two templates work the same:
A relative positional pattern is a number with a plus (+) or minus (-) sign preceding it. (It can also be a variable within parentheses, with a plus (+) or minus (-) sign preceding the left parenthesis; for details see Parsing with variable patterns.) The number specifies the relative character position at which to
split the source string. The plus or minus indicates movement right
or left, respectively, from the start of the string (for the first
pattern) or from the position of the last match. The position of the
last match is the first character of the last match. Here is the same
example as for absolute positional patterns done with relative positional
patterns:
Blanks between the sign and the number are insignificant. Therefore, +10 and + 10 have the same meaning. Note that +0 is a valid relative positional pattern. Absolute and relative positional patterns are interchangeable (except in the special case (see Combining string and positional patterns: a special case) when a string pattern precedes a variable name and a positional pattern follows the variable name). The templates from the examples of absolute and relative positional patterns give the same results. ![]() Only with positional patterns can a matching operation back
up to an earlier position in the source string. Here is an example
using absolute positional patterns:
The absolute positional pattern 1 backs up to the first character in the source string. With relative positional patterns, a number preceded by a minus
sign backs up to an earlier position. Here is the same example using
relative positional patterns:
In the previous example, the relative positional pattern -3 backs up to the first character in the source string. The templates in the last two examples are equivalent. ![]() You can use templates with positional patterns to make multiple assignments:
|
Copyright IBM Corporation 1990, 2014 |