A
character -substring is a contiguous
portion of a scalar character entity, referred to as the parent-string.
The substring is defined by giving the character positions of its
start and end. The format is:
parent-string ( [starting-position] : [ending-position])
- starting-position
is a scalar expression. If starting-position
is omitted, a value of 1 is assumed. The starting-position
must be greater than or equal to 1 unless the substring has zero
length.
- ending-position
is a scalar integer expression. If ending-position
is omitted the value of the length of the
character string is assumed.
- The length of the substring is:
MAX (ending-position - starting-position
+ 1, 0)
Following are examples of character substrings:
- 'ABCDEFGH' (3:5)
is a character substring of length 3 equal to 'CDE'.
- 'ABC' (-1 : 2)
is invalid.
- 'ABC'(2: -1)
has a zero length.