Page 1 of 1

picking some part from the string

Posted: Wed Oct 07, 2009 3:57 am
by skumar
Hi All

I have a requirement that from a particular string "The Customer has recently made an application for a new account" I need to pass the value into 2 different columns. Now the issue is in the first column is of 20 length and second column is of 150 length. when I am taking the first 20 characters from the source string the target column will be populated with the value"The Customer has rec". But I want the first column to be popualted with "The Customer has" and the second column should start/load with "recently made an application for a new account".

Can you please advise how we can acheive this.

Thanks in advance

Regards
skumar

Posted: Wed Oct 07, 2009 4:19 am
by robjones
What criteria do you need to use to break up the string into two parts?

Do you just want to take complete words up which make up 20 characters or less into the first column, and then pass the remaining complete words into the second column?

Posted: Wed Oct 07, 2009 6:03 am
by skumar
yes rob you are correct.

Posted: Wed Oct 07, 2009 6:08 am
by skumar
yes rob you are correct.

Posted: Wed Oct 07, 2009 6:16 am
by Sainath.Srinivasan
Search for Count and Index.

Posted: Wed Oct 07, 2009 6:27 am
by chulett
From what I remember, Ray has posted about the Fold() function for requirements like this. Never looked up what it did, however.

Posted: Wed Oct 07, 2009 6:34 am
by robjones
Create a stage variable, svBreak, with the following:

Code: Select all

Index(link.InputString, " ", Count(link.InputString[1,20], " ") )
Then your column derivations will be:


Col1

Code: Select all

link.InputString[1, svBreak -1]
Col2

Code: Select all

link.InputString[svBreak,150]

Posted: Wed Oct 07, 2009 6:39 am
by Sainath.Srinivasan
Fold() is a basic function that provides break by delimier.

Posted: Wed Oct 07, 2009 8:01 am
by JRodriguez
Stage Variables

sv1 = InputOrigString[1,20]
LastSv1Char = sv1[1]
sv2 = InputOrigString[21, ( len(InputOrigString) + 1)]
LastSv2Char =sv2[1,1]
svCountSpaces = count(sv1, " ")
svPosition = Index (InputOrigString, " ", svCountSpaces)


Columns derivations
targetCol1= If ( LastSv1Char <> " " and LastSv2Char <> " " ) Then InputOrigString[1, (svPosition - 1)] Else sv1
targetCol2= If ( LastSv1Char <> " " and LastSv2Char <> " " ) Then InputOrigString[svPosition, ( len(InputOrigString) - svPosition )] Else sv2