The Talend Replace data or tReplace field useful to replace a whole word or part of a word in the input rows and returns the output. We can use this Talend tReplace Replace data field to change the wrong type of data etc. In this Replacement data example, we used the Customer table.
Talend Replace or tReplace Example
First, drag and drop the DBConnection, DBCommit, and DBInput to establish a SQL Server Connection. Next, we selected the Customers table from the metadata.
Next, drag the Talend tRepalce replace data from the palette to the job design. As you can see from the below tooltip, tReplace replaces an expression with another one.
Please connect the DBInput main row to tReplace. Mostly, the input columns will sync with the tReplace. If that is not the case, click on the Sync columns button.
Within the Components tab, there is a simple mode and an advanced mode. You can use advanced mode to write a regular expression. In the Search/Replace section, we have
- InputColumn: Please select the column you want to use for search and replace.
- Search: Please provide the search term that you want to search inside the column.
- Replace with: Write the replacement term in this section.
- Whole word: If you wish to perform on the entire word or part of a word.
- Case Sensitive: Do you want to achieve the search in a case sensitive?
Before we perform anything (replace data), click the Edit Schema button to check or alter the Talend tReplace schema as per your requirements.
Next, click on the Add (plus) button. By default, it adds the first column, i.e., EmpID, and default text.
Please use the drop-down box to select the required column. Here, we chose the column as Education, Search term as Education, and Replace it with BTech.
After finishing the tRepalce Component configuration, we are using the DBOutput to save the Talend replace data output in an SQL Database. Here, we are creating the Talend_repalce table as the destination table.
Let us run the Talend Replace data tReplace Job.
Let me open the Management studio to check the Talend tReplace result.
This time, we are using two more fields and running the job. It means Talend tRepalce has to replace the Pro part (not the complete word) in the Occupation field with ABCD and John in the FirstName column with Suresh.
Please check the Talend tReplace result.
Let me select the Talend Replace field Advanced mode. As you can see, here, we can use the regexp pattern to search the string.