String functions - Cloud

Talend Data Shaping Language Reference Guide

Version
Cloud
Language
English (United States)
Product
Talend Cloud
Module
Data Shaping Language
Content
Design and Development

The following operations can be used to perform operations on strings.

Function Description Arguments Example
concat Joins several arguments into one string. Any data type can be used. Types other than string are converted to string before the function is applied. At least two strings to concatenate. Expression: concat("Hello ", "World!")

Result: "Hello World!"

concatWith Joins several arguments into one string, with a specific delimiter. Any data type can be used. Types other than string are converted to string before the function is applied.
  1. Delimiter
  2. At least two strings to concatenate.
Expression: concatWith(", ", "Smith", "John")

Result: "Smith, John"

contains Returns true if the first argument contains the second argument. Any data type can be used. Types other than string are converted to string before the function is applied. If the first argument is in bytes, the second one should be in bytes or a hex string with the prefix 0x or 0X.
  1. Input string.
  2. String to search for.
Expression: contains("1, 2, 3", 2)

Result: true

indexOf Returns the index of the second argument if it appears in the first, otherwise it returns -1. The first index is 0. Any data type can be used. Types other than string are converted to string before the function is applied. If the first argument is in bytes, the second one should be in bytes or a hex string with the prefix 0x or 0X.
  1. Input string.
  2. String to search for.
Expression: indexOf("abcd", "d")

Result: 3

left Extracts a substring with a specific length from the first argument, starting with the left-most character. Any data type can be used for the first argument. Types other than string are converted to string before the function is applied.
  1. Input string.
  2. Length of the substring to extract as an integer.
Expression: left("Hello World!", 5)

Result: "Hello"

length Returns the length of the argument. Any data type can be used. For bytes, the byte length is returned. Element for which you want to return the length. Expression: length(0xFFFF)

Result: 2

lowerCase Converts all characters in a string to lower case. Input string. Expression: lowerCase("Hello World!")

Result: "hello world!"

matches Returns true if a regular expression matches an input string.
  1. Input string.
  2. Regular expression as a string.
  3. Optional: Boolean defining whether the regular expression is case insensitive. It is false by default.
  4. Optional: Boolean defining whether the . character matches any character, including line terminators. It is true by default.
  5. Optional: Timeout in seconds as a long. It is 10 by default.
Expression: matches("Hello World!", "\w+\s\w+!", true, true, 15)

Result: true

normalizeSpace Removes excess leading or trailing whitespace. If there are multiple spaces between words, they are reduced to one space. Any whitespace non-blank characters are removed. Input string. Expression: normalizeSpace(" Hello World! ")

Result: "Hello World!"

replace Replaces characters that match a regular expression with another string.
  1. Input string.
  2. Regular expression as a string.
  3. Replacement string.
  4. Optional: Boolean defining whether the function should replace only the first occurrence. It is false by default.
  5. Optional: Timeout in seconds as a long. It is 10 by default.
Expression: replace("abc_123_456", "\d+", "000", true, 15)

Result: "abc_000_456"

right Extracts a substring with a specific length from the first argument, starting with the right-most character. Any data type can be used for the first argument. Types other than string are converted to string before the function is applied.
  1. Input string.
  2. Length of the substring to extract as an integer.
Expression: right("Hello World!", 6)

Result: "World!"

startsWith Returns true if the first argument starts with the prefix specified in the second argument. Any data type can be used. Types other than string are converted to string before the function is applied. If the first argument is in bytes, the second one should be in bytes or a hex string with the prefix 0x or 0X.
  1. Input string.
  2. Prefix.
Expression: startsWith("Hello World!", "Hello")

Result: true

endsWith Returns true if the first argument ends with the suffix specified in the second argument. Any data type can be used. Types other than string are converted to string before the function is applied. If the first argument is in bytes, the second one should be in bytes or a hex string with the prefix 0x or 0X.
  1. Input string.
  2. Suffix.
Expression: endsWith("Hello World!", "!")

Result: true

subString Returns a substring of characters starting at specific index.
  1. Input string.
  2. Index of the first character to return as an integer. The first index is 0.
  3. Length of the substring to return as an integer.
Expression: subString("Hello World!", 6, 5)

Result: "World"

translate Replaces individual characters with other individual characters.
  1. Input string.
  2. Characters to replace as a string.
  3. Replacement characters as a string.
Expression: translate("abcde", "ace", "123")

Result: "1b2d3"

trim Removes excess leading and trailing whitespace. Input string. Expression: trim(" Hello World! ")

Result: "Hello World!"

upperCase Converts all characters in a string to upper case. Input string. Expression: upperCase("Hello World!")

Result: "HELLO WORLD!"