Split and Interchange string text

Highlighted
Five Stars

Split and Interchange string text

Hi all,

 

I want to split the string into two halves and then interchange in the tmap.

Ex: my string is of length 8,  ABCDEFGH

I want the output as EFGHABCD

 

Please suggest a solution.


Accepted Solutions
Employee

Re: Split and Interchange string text

Hi,

 

   Assuming the input is a not null column and always have 8 characters, please see the solution below.

image.png

 

image.png

 

row1.data.substring(4,8)+row1.data.substring(0,4)

You can check the length of the string as a parameter to function, if you want to change it dynamically for varying string length.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)


All Replies
Employee

Re: Split and Interchange string text

Hi,

 

   Assuming the input is a not null column and always have 8 characters, please see the solution below.

image.png

 

image.png

 

row1.data.substring(4,8)+row1.data.substring(0,4)

You can check the length of the string as a parameter to function, if you want to change it dynamically for varying string length.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

Five Stars

Re: Split and Interchange string text

Thanks for the Perfect response.
I needed this implementation in interchanging different date formats where i get feed name_date differently. It solved my issue.

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch