RTRIM examines a data string from right to left and compares the contents to an exclusion character string. If a match is found between data string and the exclusion character string, the RTRIM function removes the characters which match the exclusion character string. RTRIM continues until the first non-matching character is found. It also provides flexibility regarding the method of comparison by specifying either the ANY or MATCH parameter. Note that for single character exclusion strings, ANY and MATCH will return the same results. A common use of RTRIM is to remove spaces from the right side of a string.
Category
String
Syntax
RTRIM(data_string, trim_character_string, 'ANY' | 'MATCH' )
Parameters and Descriptions
Parameter | Description |
---|---|
data_string | The data string in character format. The data string can be a field from a source datastore, a variable, a constant or the result of another Function. |
trim_character_string |
One (1) or more characters that specify the characters to exclude from the right hand side of the data string. Exclusion characters may be a field of a source datastore, a literal value or the output of another Function. |
ANY | MATCH |
Denotes the type of matching from the right side of a source data string based on the contents of the exclusion character string. Note that these parameters must be enclosed in single quotes.
|
Example
TARGET.FIELD = RTRIM(SOURCE.FIELD, 'D', 'MATCH')
TARGET.FIELD = RTRIM('ABCD', 'D', 'MATCH')
TARGET.FIELD = RTRIM(VARIABLE, 'D', 'MATCH')
TARGET.FIELD = RTRIM(FUNCTION(SOURCE.FIELD), 'D', 'MATCH')
--Assuming SOURCE.FIELD = 'ABCD', VARIABLE = 'ABCD', and the result of
--FUNCTION(SOURCE.FIELD) = 'ABCD' the results would be 'ABC' for all cases.
TARGET.FIELD = RTRIM('ABCD', SOURCE.FIELD, 'MATCH')
TARGET.FIELD = RTRIM('ABCD', 'D', 'MATCH')
TARGET.FIELD = RTRIM('ABCD', VARIABLE, 'MATCH')
TARGET.FIELD = RTRIM('ABCD', FUNCTION(SOURCE.FIELD), 'MATCH')
--Assuming SOURCE.FIELD = 'D', VARIABLE = 'D', and the result of
--FUNCTION(SOURCE.FIELD) = 'D' the results would be 'ABC' for all cases.
TARGET.FIELD = RTRIM(SOURCE.FIELD, 'D', 'MATCH')
TARGET.FIELD = RTRIM(SOURCE.FIELD, 'D', 'ANY')
--Assuming SOURCE.FIELD = 'ABCD', the result would be 'ABC' for either case.
TARGET.FIELD = RTRIM(SOURCE.FIELD, 'A', 'MATCH')
TARGET.FIELD = RTRIM(SOURCE.FIELD, 'A', 'ANY')
--Assuming SOURCE.FIELD = 'BCDAAA', the result would be 'BCD' for either case.
TARGET.FIELD = RTRIM(SOURCE.FIELD, 'AB', 'MATCH')
--Assuming SOURCE.FIELD = 'CDABAB', the result would be 'CD'.
TARGET.FIELD = RTRIM(SOURCE.FIELD, 'ABC', 'ANY')
--Assuming SOURCE.FIELD = 'ADCABC', the result would be 'AD'.