RTRIM$ function

Purpose

Return a copy of a string with trailing characters or strings removed.

Syntax

x$ = RTRIM$(MainString [, [ANY] MatchString])

Remarks

MainString is the string expression from which to remove characters, and MatchString is the string expression specifying the characters that should be removed from the right hand side of MainString.

If MatchString is not specified, RTRIM$ removes trailing spaces.  RTRIM$ returns a sub-string of MainString, from the beginning of the string to the character preceding the consecutive occurrences of MatchString (or space), which continues to the end of the original string.  If MatchString (or a space) is not present at the end of MainString, all of MainString is returned.

RTRIM$ is case-sensitive.

ANY

If the ANY keyword is included, MatchString specifies a list of single characters to be searched for individually - a match on any one of which as a trailing character will cause the character to be removed from the result.

See also

EXTRACT$, INSTR, LEFT$, LTRIM$, MID$, REMOVE$, REPLACE, RIGHT$, STRDELETE$, STRINSERT$, STRREVERSE$, TALLY, TRIM$, VERIFY

Example

' returns "abacadabra" (match on spaces)

x$ = RTRIM$("abacadabra   ")

 

' returns "abacadabra   " (no match on " cad")

x$ = RTRIM$("abacadabra   ", " cad")

 

' returns "abacadabr" (match on " " and "a")

x$ = RTRIM$("abacadabra   ", ANY " cad")