StringHandling Routines - 6.1

Talend Data Fabric Studio User Guide

EnrichVersion
6.1
EnrichProdName
Talend Data Fabric
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

The StringHandling routines allow you to carry out various kinds of operations and tests on alphanumeric expressions, based on Java methods.

To access these routines, doubleclick on StringHandling under the system folder. The StringHandling class includes the following routines:

Routine

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")

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("chaîne à vérifier", 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")

How to store a string in alphabetical order

It is easy to use the ALPHA routine along with a tJava component, to check whether a string is in alphabetical order:

System.out.println(StringHandling.ALPHA("abcdefg"));

The check returns a boolean value.

How to check whether a string is alphabetical

It is easy to use the IS_ALPHA routine along with a tJava component, to check whether the string is alphabetical:

System.out.println(StringHandling.IS_ALPHA("ab33cd"));

The check returns a boolean value.

How to replace an element in a string

It is easy to use the CHANGE routine along with a tJava component, to replace one element in a string with another:

System.out.println(StringHandling.CHANGE("hello world!", "world", "guy"));

The routine replaces the old element with the new element specified.

How to check the position of a specific character or substring, within a string

The INDEX routine is easy to use along with a tJava component, to check whether a string contains a specified character or substring:

System.out.println(StringHandling.INDEX("hello world!", "hello"));
System.out.println(StringHandling.INDEX("hello world!", "world")); 
System.out.println(StringHandling.INDEX("hello world!", "!")); 
System.out.println(StringHandling.INDEX("hello world", "?"));

The routine returns a whole number which indicates the position of the first character specified, or indeed the first character of the substring specified. Otherwise, - 1 is returned if no occurrences are found.

How to calculate the length of a string

The LEN routine is easy to use, along with a tJava component, to check the length of a string:

System.out.println(StringHandling.LEN("hello world!"));

The check returns a whole number which indicates the length of the chain, including spaces and blank characters.

How to delete blank characters

The FTRIM routine is easy to use, along with a tJava component, to delete blank characters from the start of a chain:

System.out.println(StringHandling.FTRIM("  Hello world  !"));

The routine returns the string with the blank characters removed from the beginning.