Table of Contents

Search

  1. Preface
  2. Taskflows and linear taskflows
  3. Taskflows
  4. Linear taskflows

Taskflows

Taskflows

ltrim

ltrim

Removes leading spaces or characters from the beginning of a string.
If you do not specify the
trim_set
argument in the expression, ltrim removes both single-byte and double-byte spaces from the beginning of a string.
If you use ltrim to remove characters from a string, ltrim compares the
trim_set
to each character in the
str
argument, character-by-character, starting from the left side of the string. If the character in the string matches any character in the
trim_set
, ltrim removes it. The ltrim function continues comparing and removing characters until it fails to find a matching character in the
trim_set
. Then it returns the string, which does not include matching characters.

Syntax

sff:ltrim(str, trim_set)
The following table describes the arguments:
Arguments
Required/
Optional
Description
str
Required
Any string value. Passes the strings that you want to modify. You can enter any valid transformation expression. Use operators to perform comparisons or concatenate strings before removing characters from the beginning of a string.
You must enclose the string value within single or double quotation marks.
To pass a NULL value, you must specify an empty sequence in the following format:
()
trim_set
Optional
Any string value. Passes the characters that you want to remove from the beginning of the first string. You can enter any valid transformation expression. You can also enter a character string.
You must enclose the trim set value within single or double quotation marks.
To pass a NULL value, you must specify an empty sequence in the following format:
()
The ltrim function is case sensitive. For example, if you want to remove the 'A' character from the string 'Alfredo', you would enter 'A', not 'a'.

Return Value

String. The string values with the specified characters in the
trim_set
argument removed.
NULL if a value passed to ltrim is NULL. If the
trim_set
is NULL, ltrim returns NULL.

Example

The following expression removes the characters ‘
S
’ and ‘
.
’ from the strings in the LAST_NAME column:
sff:ltrim( LAST_NAME, 'S.')
The following table lists some sample values and return values:
LAST_NAME
RETURN VALUE
Nelson
Nelson
Osborne
Osborne
NULL
NULL
S. MacDonald
MacDonald
Sawyer
awyer
H. Bender
H. Bender
Steadman
teadman
The ltrim function removes ‘S.’ from S. MacDonald and the ‘S’ from both Sawyer and Steadman, but not the period from H. Bender. This is because ltrim searches, character-by-character, for the set of characters you specify in the
trim_set
argument. If the first character in the string matches the first character in the
trim_set
, ltrim removes it. Then, ltrim looks at the second character in the string. If it matches the second character in the
trim_set
, ltrim removes it, and so on. When the first character in the string does not match the corresponding character in the
trim_set
, ltrim returns the string and evaluates the next row.
In the example of H. Bender, H does not match either character in the
trim_set
argument, so ltrim returns the string in the LAST_NAME column and moves to the next row.

Tips for ltrim

Use ltrim with CONCAT to remove leading blank spaces after you concatenate two strings.
You can also remove multiple sets of characters by nesting ltrim. For example, to remove leading blank spaces and the character 'T' from a column of names, you might create an expression as follows:
sff:ltrim( sff:ltrim( NAMES ), 'T' )

0 COMMENTS

We’d like to hear from you!