Page 1 of 1

Need to Insert a character in a string at particular positio

Posted: Thu Feb 09, 2012 2:36 am
by deepa.y
Hi,
I have an input string "AAABCCDEK".I want to insert a character '^' at 4th and 8th position of the string using transformer stage.
My output should look like this "AAA^BCC^DEK".
Can somebody help me out in this logic?

Posted: Thu Feb 09, 2012 2:46 am
by ray.wurlod
Assuming the string is exactly nine characters long:

Code: Select all

InLink.TheString[1,3] : "^" : InLink.TheString[4,3] : "^" : InLink.TheString[7,3]

Posted: Thu Feb 09, 2012 2:58 am
by deepa.y
The length of input string will vary but position of characters to be inserted will be at 4th and 8th only.

Posted: Thu Feb 09, 2012 3:03 am
by pandeesh
So you need to len() function also:

Code: Select all

InLink.TheString[1,3] : "^" : InLink.TheString[4,3] : "^" : InLink.TheString[7,len(InLink.TheString)-6]

Posted: Thu Feb 09, 2012 3:12 am
by deepa.y
Thanks Ray
Thanks Pandeesh
That worked fine.
I am resolving this topic

Posted: Thu Feb 09, 2012 3:25 am
by pandeesh
Welcome!!