trim trailing characters

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
lfong
Premium Member
Premium Member
Posts: 42
Joined: Fri Sep 09, 2005 7:48 am

trim trailing characters

Post by lfong »

I am trying to trim all trailing characters after a '(' eg. abcdef (xxxx) would become abcdef
The trim function will not work because the trailing or leading function will only remove the '('.

What would be the best way to do this?

Thanks
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Forget the trim function. Use the Field() function to extract everything before "(".

Code: Select all

Field(in.Col, "(", 1)
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Trim can eliminate whitespace or tabs or spaces or any given character not any character that are available. DSguru2B suggestion should be more simple to your requirement.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Simple ,yes ; efficient, I dont know about that. I belive, using INDEX() to get the position of "(" and use it in substring ([1,x]) where x will be the position returned by INDEX().
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Which is exactly how Field() works.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

ray.wurlod wrote:Which is exactly how Field() works.
Hmm, did'nt know that. But makes sense. So it is safe to say that Field() is equivalent to INDEX() with substring, in efficiency?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Probably. Write it yourself in C, just to prove the point.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

ray.wurlod wrote:Probably. Write it yourself in C, just to prove the point.
Nah. Even if there is a difference, it must be negligible.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply