Tabular IQ
Back to Function Index

LTRIM()

Overview

LTRIM() removes characters from the left side of a string. It iteratively removes any leftmost character that matches any character in the specified list. If no list is provided, LTRIM() removes spaces from the left side. This function is useful for string cleaning, data normalization, and text formatting. LTRIM() is similar to TRIM() (which removes from both sides) and RTRIM() (which removes from the right side).

Function Format

LTRIM(string [, list])

Return Value

LTRIM() returns a character string

Examples


LTRIM(" APPLES ") = "APPLES "              (removes leading spaces)
LTRIM("APPLES", "A") = "PPLES"             (removes single character)
LTRIM("APPLES", "AP") = "LES"              (removes multiple characters)
LTRIM("APPLES", "P") = "APPLES"            (no matching leftmost character)
LTRIM("APPLES", "PA") = "LES"              (removes characters in any order)
LTRIM("APPLES", "APS") = "LES"             (removes all matching characters)
LTRIM("ABRACADABRA", "ABRC") = "DABRA"     (complex pattern removal)
LTRIM("ABRACADABRA", "ABRCD") = ""         (removes all characters)
LTRIM("", "ABC") = ""                      (empty string)
LTRIM(NULL, "ABC") = NULL                  (NULL input)

Notes

  • Important behaviors:
    • Removes characters only from the left side
    • Processes characters iteratively from left to right
    • Removes any character that matches the list
    • Default behavior removes spaces if no list provided
    • Returns NULL for NULL input
  • Common use cases include:
    • String cleaning
    • Data normalization
    • Text formatting
    • Input validation
    • Data preprocessing
  • The function can be used with:
    • String literals
    • String columns
    • String expressions
    • String functions
  • This function is often used in combination with other string functions like RTRIM(), TRIM(), and REPLACE() for more complex string manipulations.
  • For removing characters from both sides, use TRIM() instead.
  • For removing characters from the right side only, use RTRIM() instead.

See Also