Variable substringing
To access only a part (a substring) of a variable, specify a starting position and an optional length of the substring.
Append a colon (:) to the end of the variable name followed by a numeric designating the base position. Positions start at 1 (not zero) and cannot be longer than the length of the variable.
Optionally, another colon may follow a substring specification that can designate the total length of the character string to evaluate.
Defaults
If a substring specification extends past the end of a variable, only the portions that could properly be evaluated are returned.
Invalid specifications
If a substring specification cannot be properly evaluated because of an invalid specification, it will be evaluated to the extent that specifications are valid.
Examples
For the following examples, assume the variable ABC contains the character string THIS IS A TEST
If you specify | The result is |
---|---|
&ABC:11 | TEST |
&ABC:1:4 | THIS |
&ABC:11:38 | TEST |
&ABC:6:NOT | IS A TEST:NOT This example shows that you can add more characters that are appended to the value returned from the substringing operation. |