How to start get strings when end with a string?

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
ylai20
Participant
Posts: 15
Joined: Tue Jun 08, 2010 10:12 pm

How to start get strings when end with a string?

Post by ylai20 »

Hi, i have a column has this kind of text:
This house is belongs to Andy
This car is belongs to Kelvin

I want the column return me the result of "Andy" & "Kelvin", which means I will only start to take the string after it read "to "

Any idea how to do do it? Thanks!
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

Try with the below derivation.

Field(InputCol[ Index(InputCol,"to ",1),(Len(InputCol)-Index(InputCol,"to ",1))+1]," ",2)
Cheers
Ravi K
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Or, slightly more simply

Code: Select all

InLink.TheField[Index(InLink.TheField, " to ",1) + 4, 999999]
This method relies on the fact that the string returned by the substring operator ends at the end of the source string no matter how many characters were actually requested in the substring operator.

Note also the spaces around the "to". This allows the field to contain something like "This store belongs to Arnold". (There's a "to" in "store".)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply