Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Gurus,
how is it the best practice to insert some "-" characters inside another string to format the code?
for example, i have a code of xxxxxxxx digit and i want turn it in x-xxx-xxxx.
Thanks for your help
No idea if it is the best option but I would split the code and concatenate with "-", you can do it all in a tmap component.
I add trhee rows in tmap1 and compute the single part of the code.
StringHandling.LEFT(dt.trainings_code_formatted,1) first part of the code COD1
StringHandling.LEFT(StringHandling.RIGHT(dt.trainings_code_formatted,7),3) middle part of the code COD2
StringHandling.RIGHT(dt.trainings_code_formatted,4) last part of the code COD3
In tmap2 i concatenate the different fields
dt1.COD1 + "-" + dt1.COD2 + "-" + dt1.COD3
Thank you for your answer. What tMap components do you use in order to accomplish this task? can you post a little script?
Thanks
I don't really know if these options are better than the one you already did. They are practically the same.
Option 1)
StringHandling.LEFT(dt.trainings_code_formatted,1) + "-" + StringHandling.LEFT(StringHandling.RIGHT(dt.trainings_code_formatted,7),3) + "-" + StringHandling.RIGHT(dt.trainings_code_formatted,4)
Option 2)
In the tmap do variables where you calculate CODE1, CODE2 and CODE3 and in you output field the CODE1+ "-" +CODE2+ "-" +CODE3.