Page 1 of 2

Extracting String

Posted: Wed Nov 08, 2006 8:15 pm
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

Posted: Wed Nov 08, 2006 8:19 pm
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.

Posted: Wed Nov 08, 2006 8:24 pm
by pradkumar
Thanks for the reply.
yes, I want to remove only X.

How to do it. can you give an example

Posted: Wed Nov 08, 2006 8:28 pm
by I_Server_Whale
Search the forum for EReplace or Convert key words. You will find many posts with examples.

Whale.

Posted: Wed Nov 08, 2006 8:29 pm
by pradkumar
I got it..

Thanks

Posted: Wed Nov 08, 2006 8:30 pm
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.

Posted: Wed Nov 08, 2006 8:34 pm
by kris007
Try this

Code: Select all

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

Posted: Wed Nov 08, 2006 8:35 pm
by kris007
Aah. He beat us both Craig :lol:

Posted: Wed Nov 08, 2006 9:15 pm
by chulett
Damn my slow fingers. :lol:

Posted: Wed Nov 08, 2006 10:00 pm
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

Re: Extracting String

Posted: Thu Nov 09, 2006 3:02 am
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.

Re: Extracting String

Posted: Thu Nov 09, 2006 3:02 am
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.

Posted: Thu Nov 09, 2006 6:21 am
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

Posted: Thu Nov 09, 2006 7:06 am
by DSguru2B
What solution did you use pradkumar?
You can also mark this post as resolved now. :)

Posted: Thu Nov 09, 2006 8:20 am
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.