Extracting String

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

pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Extracting String

Post by pradkumar »

Hi

I am having a key column like
888888X
988888X
sgahjhasjk
737326X

I would like the output to be
888888
988888
sgahjhasjk
737326

ie only keys which end with X in input should not have that X in output
Pradeep Kumar
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So... you want to remove an 'X' from the field in question? Anything more to it than that, like perhaps it needs to be the last character in the field?

If not, then a simple EReplace or Convert call to change it to an empty string (i.e. remove it) will do the trick.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

Thanks for the reply.
yes, I want to remove only X.

How to do it. can you give an example
Pradeep Kumar
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

Search the forum for EReplace or Convert key words. You will find many posts with examples.

Whale.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
pradkumar
Charter Member
Charter Member
Posts: 393
Joined: Wed Oct 18, 2006 1:09 pm

Post by pradkumar »

I got it..

Thanks
Pradeep Kumar
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I gave you the names of two functions that will work for you. How about you take a second and check the Help available for them and work it out? That's how one learns... much better than if someone just hands you a solution on a silver platter.

Give it a shot, if you still have problems come back.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

Try this

Code: Select all

Ereplace(Input.Column, "X", "") 
and you can use Trim to trim the spaces. :wink:
Kris

Where's the "Any" key?-Homer Simpson
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

Aah. He beat us both Craig :lol:
Kris

Where's the "Any" key?-Homer Simpson
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Damn my slow fingers. :lol:
-craig

"You can never have too many knives" -- Logan Nine Fingers
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

ie only keys which end with X in input should not have that X in output
Using Matches operator or Colname[Len(Colname)]='X' could be a more suitable for this, before chopping the last X and use Left operator for removing the training
Success consists of getting up just one more time than you fall.
uppalapati2003
Participant
Posts: 70
Joined: Thu Nov 09, 2006 2:14 am

Re: Extracting String

Post by uppalapati2003 »

pradkumar wrote:Hi

I am having a key column like
888888X
988888X
sgahjhasjk
737326X

I would like the output to be
888888
988888
sgahjhasjk
737326

ie only keys which end with X in input should not have that X in output




hi ,
u can use if substrings(sttring name,len(string),length(string))='x' then
substring(string name,1,len(string)-1)) else input stringname.
Srini
uppalapati2003
Participant
Posts: 70
Joined: Thu Nov 09, 2006 2:14 am

Re: Extracting String

Post by uppalapati2003 »

pradkumar wrote:Hi

I am having a key column like
888888X
988888X
sgahjhasjk
737326X

I would like the output to be
888888
988888
sgahjhasjk
737326

ie only keys which end with X in input should not have that X in output




hi ,
u can use if substrings(sttring name,len(string),length(string))='x' then
substring(string name,1,len(string)-1)) else input stringname.
Srini
Raghavendra
Participant
Posts: 147
Joined: Sat Apr 30, 2005 1:23 am
Location: Bangalore,India

Post by Raghavendra »

You can achieve this with Index function also.
Find the position of 'X' with index function then you remove 'X' with substrings function
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

What solution did you use pradkumar?
You can also mark this post as resolved now. :)
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Jeez, why make it more complicated than it needs to be when a simple solution has already been posted? :?

Code: Select all

Convert("X","",TheField)

-or-

Code: Select all

EReplace(TheField,"X","")
The OP hasn't mentioned anything that would require the solution be any more involved than that.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply