how to get the last word after space

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
arnie_nits
Participant
Posts: 101
Joined: Mon Aug 13, 2007 2:32 am

how to get the last word after space

Post by arnie_nits »

Hi ,

I have a requirement where I need to get the last word after space..e.g:
from ABC XYZ I should pick XYZ and from ABC XYZ ASD I should pick ASD....

Please suggest...
Regards,
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

One solution: use DCount() to get the number of fields then use that count in the Field() function to get the last field:

Code: Select all

Field(YourField," ",DCount(YourField," "),1)
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If DCount() is identified as invalid when you validate the expression, use Count() instead.

Code: Select all

Field(YourField," ",Count(YourField," ")+1,1)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Curious under what circumstances DCount() might be considered invalid? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

For example, if DCount() were not in the DSParams file, which did happen in one point release. Or if DCount() has been removed from DSParams.
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