TRIM
TRIM returns a nonvarying character string with characters trimmed from one or both ends.
- x, y, and z
- Expressions.
Each must have a computational type and should have CHARACTER type or UCHAR type. If not, they are converted.
x is the string from which the characters defined by y are trimmed from the left, and the characters defined by z are trimmed from the right.
If z is omitted, it defaults to a CHARACTER(1) NONVARYING string containing one blank.
If y and z are both omitted, they both default to a CHAR(1) NONVARYING string containing one blank.
Example
In the
following example, the TRIM function removes
- all the blanks from the left side of the string.
- all the blanks and all the asterisks from the right side of the string.
dcl Source char value(" *** PL/I's got the Power! *** ");
dcl Target char(length(Source)) varying;
Target = trim(Source, ' ', '* ');
/* "*** PL/I's got the Power!" */