Skip to main content

StringHandling routine

The StringHandling routine contains several functions which allow you to carry out various kinds of operations and tests on alphanumeric expressions, based on Java methods.

You can access these functions by double-clicking the StringHandling node under the system routines folder in the Repository tree view.

Functions of the StringHandling routine

Function

Description

Syntax

ALPHA

Checks whether the expression is arranged in alphabetical order. Returns the true or false boolean accordingly.

StringHandling.ALPHA("string to be checked")

IS_ALPHA

Checks whether the expression contains alphabetical characters only, or otherwise. Returns the true or false boolean accordingly.

StringHandling.IS_ALPHA("string to be checked")

CHANGE

Replaces an element of a string with a defined replacement element and returns the new string.

StringHandling.CHANGE("string to be checked", "string to be replaced","replacement string")

COUNT

Returns the number of times a substring occurs within a string.

StringHandling.COUNT("string to be checked", "substring to be counted")

DOWNCASE

Converts all uppercase letters in an expression into lowercase and returns the new string.

StringHandling.DOWNCASE("string to be converted")

UPCASE

Converts all lowercase letters in an expression into uppercase and returns the new string.

StringHandling.UPCASE("string to be converted")

DQUOTE

Encloses an expression in double quotation marks.

StringHandling.DQUOTE("string to be enclosed in double quotation marks")

EREPLACE

Substitutes all substrings that match the given regular expression in the given old string with the given replacement and returns a new string.

StringHandling.EREPLACE(oldStr, regex, replacement)

INDEX

Returns the position of the first character in a specified substring, within a whole string. If the substring specified does not exist in the whole string, the value -1 is returned.

StringHandling.INDEX("string to be checked", "substring specified")

LEFT

Specifies a substring which corresponds to the first n characters in a string.

StringHandling.LEFT("string to be checked", number of characters)

RIGHT

Specifies a substring which corresponds to the last n characters in a string.

StringHandling.RIGHT("string to be checked", number of characters)

LEN

Calculates the length of a string.

StringHandling.LEN("string to check")

SPACE

Generates a string consisting of a specified number of blank spaces.

StringHandling.SPACE(number of blank spaces to be generated)

SQUOTE

Encloses an expression in single quotation marks.

StringHandling.SQUOTE("string to be enclosed in single quotation marks")

STR

Generates a particular character a the number of times specified.

StringHandling.STR('character to be generated', number of times)

TRIM

Deletes the spaces and tabs before the first non-blank character in a string and after the last non-blank character, then returns the new string.

StringHandling.TRIM("string to be checked")

BTRIM

Deletes all the spaces and tabs after the last non-blank character in a string and returns the new string.

StringHandling.BTRIM("string to be checked")

FTRIM

Deletes all the spaces and tabs preceding the first non-blank character in a string.

StringHandling.FTRIM("string to be checked")

SUBSTR

Returns a portion of a string. It counts all characters, including blanks, starting at the beginning of the string.

StringHandling.SUBSTR(string, start, length)

  • string: the character string you want to search.

  • start: the position in the string where you want to start counting.

  • length: the number of characters you want to return.

LTRIM

Removes blanks or characters from the beginning of a string.

StringHandling.LTRIM(string[, trim_set])

  • string: the string you want to change.

  • trim_set: the characters you want to remove from the beginning of the string. LTRIM will compare the trim_set to the string character-by-character, starting with the left side of the string, and remove characters until it fails to find a matching character in the trim_set. If this parameter is not specified, LTRIM will remove any blanks from the beginning of the string.

RTRIM

Removes blanks or characters from the end of a string.

StringHandling.RTRIM(string[, trim_set])

  • string: the string you want to change.

  • trim_set: the characters you want to remove from the ending of the string. RTRIM will compare the trim_set to the string character-by-character, starting with the right side of the string, and remove characters until it fails to find a matching character in the trim_set. If this parameter is not specified, RTRIM will remove any blanks from the ending of the string.

LPAD

Converts a string to a specified length by adding blanks or characters to the beginning of the string.

StringHandling.LPAD(first_string, length[, second_string])

  • first_string: the string you want to change.

  • length: the length you want the string to be after being padded.

  • second_string: the characters you want to append to the left side of the first_string.

RPAD

Converts a string to a specified length by adding blanks or characters to the end of the string.

StringHandling.RPAD(first_string, length[, second_string])

  • first_string: the string you want to change.

  • length: the length you want the string to be after being padded.

  • second_string: the characters you want to append to the right side of the first_string.

INSTR

Returns the position of a character set in a string, counting from left to right and starting from 1.

Note that it returns 0 if the search is unsuccessful and NULL if the search value is NULL.

StringHandling.INSTR(string, search_value, start, occurrence)

  • string: the string you want to search.

  • search_value: the set of characters you want to search for.

  • start: the position in the string where you want to start the search. The default is 1, meaning it starts the search from the first character in the string.

  • occurrence: the occurrence you want to search for.

For example, StringHandling.INSTR("Talend Technology", "e", 3, 2), it will start the search from the third character l and return 7, the position of the second character e.

INSTR

Returns the position of a byte set in a string, counting from left to right and starting from 1.

Note that it returns 0 if the search is unsuccessful and NULL if the search value is NULL.

StringHandling.INSTR(byte[] string, byte[] search_value, start, occurrence)

  • string: the string you want to search.

  • search_value: the set of characters you want to search for.

  • start: the position in the string where you want to start the search. The default is 1, meaning it starts the search from the first character in the string.

  • occurrence: the occurrence you want to search for.

TO_CHAR

Converts numeric values to text strings.

StringHandling.TO_CHAR(numeric_value)

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!