Tabular IQ
Back to Function Index

RTRIM()

Overview

RTRIM() removes specified characters from the right side of a string. It iteratively removes characters that match any character in the provided list, starting from the rightmost position. If no list is provided, it removes spaces by default. This function is similar to TRIM() and LTRIM(), but operates only on the right side of the string.

Function Format

RTRIM(string [, list])

Return Value

RTRIM() returns a character string

Examples


// Removing spaces (default)
RTRIM(" APPLES ") = " APPLES"

// Removing single character
RTRIM("APPLES", "S") = "APPLE"

// Removing multiple characters
RTRIM("APPLES", "SE") = "APPL"
RTRIM("APPLES", "ES") = "APPL"

// No matching characters
RTRIM("APPLES", "E") = "APPLES"

// Complex character removal
RTRIM("APPLES", "ELP") = "APPLES"
RTRIM("APPLES", "ELPS") = "A"
RTRIM("ABRACADABRA", "ARBD") = "ABRAC"
RTRIM("ABRACADABRA", "ARBDC") = ""

Notes

  • Important behaviors:
    • Removes characters from right side only
    • Iteratively processes each character in the list
    • Removes spaces by default if no list provided
    • Process continues until no more matches found
    • Order of characters in list doesn't matter
  • Common use cases include:
    • String cleaning
    • Data normalization
    • Format standardization
    • Text processing
    • Pattern removal
  • The function is useful for:
    • Right-side character removal
    • String formatting
    • Data cleaning
    • Pattern matching
  • Comparison with other trim functions:
    • RTRIM() removes from right side only
    • LTRIM() removes from left side only
    • TRIM() removes from both sides
    • All support custom character lists

See Also