Code routines enable the developer to create re-usable Java classes that can be integrated into Talend jobs, and in particular within tMap
.
In the validation chapter, there is an example of a simple code routine. This recipe is a fuller explanation of creating and using code routines within Talend.
In the metadata section, open the
Code
folder and right-click on Routines. Select Create routine.Name the routine
regexUtilities
and click on Finish. This will open a Java package and create a new class called regexUtilities, and a test method calledhelloExample
.Copy the following code immediately after the end of the
helloExample
method./** * regexData: return the first instance of regex pattern in a string. * Returns null if there is no text matching the pattern. * e.g. regexData(".*r", "world") # returns "wor" * * {talendTypes} String * ...