Page 1 of 1

To find out the substring and concat with field separator

Posted: Sun Jan 24, 2010 8:50 pm
by muralisankarr
Hi,

I have a column DESC_ which has values like the below one

DESC_
-----------
ABC
ABCXYZ
XYZ
NULL
ZZZAAABBB

I need to append comma after every 3 character.
DESC_
-----------
ABC
ABC,XYZ
XYZ
NULL
ZZZ,AAA,BBB

Please hint me with some logic to accomplish this.

Many Thanks
MSR

Posted: Sun Jan 24, 2010 9:10 pm
by ray.wurlod
Use a BASIC Transformer stage and the following expression:

Code: Select all

Convert(@FM, ",", Fold(InLink.DESC_, 3))
or this one:

Code: Select all

Convert(@TM, ",", Fmt(InLink.DESC_, "3L"))

Posted: Mon Jan 25, 2010 3:38 am
by prasoon
This will also give the same result
Ereplace(Fold(InLink.DESC_,3),@FM,',')

Posted: Mon Jan 25, 2010 3:36 pm
by ray.wurlod
... which still requires a BASIC Transformer stage because of the Fold() function. Further, Convert() is a more lightweight function than Ereplace().