Skip to content

ltrim

Description

Removes whitespace from the start of a string while leaving the end unchanged.

Syntax

Like many functions in DataPrime, ltrim supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.

ltrim(value: string): string
(value: string).ltrim(): string

Arguments

NameTypeRequiredDescription
valuestringtrueThe string to trim

Example

Clean up an extracted username

Consider the following document:

{
  "message": "user  Chris has logged in"
}

Extracting the username produces a leading space:

{
  "message": "user  Chris has logged in",
  "my_data": {
    "user": " Chris"
  }
}

Use ltrim to remove the unwanted space:

replace my_data.user with ltrim(my_data.user)
replace my_data.user with my_data.user.ltrim()

Output

{
  "message": "user  Chris has logged in",
  "my_data": {
    "user": "Chris"
  }
}