String Manipulation Functions
AMPS provides a set of functions for manipulating strings.
SUBSTR
SUBSTR
SUBSTR(string, starting_position, [length])
Returns a portion of the input string, starting at the starting_position
and ending after the specified length
.
Parameters
string
: The string to process.starting_position
: The 1-based position to start the substring. A negative number counts backward from the end of the string.length
: Optional. The length of the substring. If not provided, returns the rest of the string.
Returns
The extracted substring.
TRIM
TRIM
TRIM(string, [characters_to_trim])
Returns the input string, with all leading and trailing characters in the set of characters_to_trim
removed.
Parameters
string
: The string to transform.characters_to_trim
: Optional. The set of characters to trim. Defaults to a space.
Returns
The trimmed string.
LTRIM
LTRIM
LTRIM(string, [characters_to_trim])
Returns the input string, with all leading characters in the set of characters_to_trim
removed.
Parameters
string
: The string to transform.characters_to_trim
: Optional. The set of characters to trim. Defaults to a space.
Returns
The left-trimmed string.
RTRIM
RTRIM
RTRIM(string, [characters_to_trim])
Returns the input string, with all trailing characters in the set of characters_to_trim
removed.
Parameters
string
: The string to process.characters_to_trim
: Optional. The set of characters to trim. Defaults to a space.
Returns
The right-trimmed string.
LEFT
LEFT
LEFT(string, number_of_characters)
Returns the leftmost number_of_characters
from the provided string.
Parameters
string
: The string to process.number_of_characters
: The number of characters to return from the left.
Returns
The leftmost characters of the string.
RIGHT
RIGHT
RIGHT(string, number_of_characters)
Returns the rightmost number_of_characters
from the provided string.
Parameters
string
: The string to process.number_of_characters
: The number of characters to return from the right.
Returns
The rightmost characters of the string.
REVERSE
REVERSE
REVERSE(string)
Returns the provided string in reverse.
Parameters
string
: The string to process.
Returns
The reversed string.