Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
Being a recent convert from DataStage to Talend I am looking for a string function which does the equivalent of the Field function in DataStage. Here's how the Field function works:
MainString = "AAA;BBB;CCC;DDD"
X = Field(MainString, ';', 3) = "CCC"
The function recognises a "string to search" - MainString, a separator - ";", and the index of the substring - 3
I would be grateful if anyone can suggest how this functionality can be replicated in a tmap column derivation expression?
Many thanks,
Bob
Thank you both, I thought it might be in there somewhere!
try {
x = MainString.split(";")[2];
}catch ( Exception e) {
x = "Not found";
}
Hi @bob_oxtoby
First of all, welcome to the world of Talend 🙂
Below is a slightly different version of Abhi's solution using tMap where I am using context variables to pass the separator and index to pick.
row1.data.split(context.separator)[context.index]
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 🙂
Thank you both, I thought it might be in there somewhere!