Page 1 of 1

Is there a way to remove characters from String except 0-9

Posted: Sat Apr 09, 2005 2:47 am
by tombastian
Hi All,
In DataStage, is there any way to remove all the characters from a String except digits 0 to 9.

Thanks In Advance,
Tom.

Posted: Sat Apr 09, 2005 6:48 am
by morneh
Only way I've been able to do it was to write a routine that check each character and if it's not A - Z or 0 - 9 then it would skip it and continue to the next.

If it is one of the wanted characters, it would concat it to a new string and at the end of the routine pass back this "cleaned up" string to you.

Obviously running this through a lot of data does impact your performance quite heavily.

Re: Is there a way to remove characters from String except 0

Posted: Sat Apr 09, 2005 7:31 am
by naren6876
Use Result = Oconv("InputString","MCN")
tombastian wrote:Hi All,
In DataStage, is there any way to remove all the characters from a String except digits 0 to 9.

Thanks In Advance,
Tom.

Posted: Sat Apr 09, 2005 8:28 am
by ArndW
Naren's post is correct, just remember to remove the quotes around the first parameter 8)

Posted: Sat Apr 09, 2005 8:37 am
by chulett
Or something a little less obtuse:

Code: Select all

DIGITS(YourField)
Does the exact same Oconv under the covers but at least you have an idea what is going on. Check out the other Transforms that come with the product, there's some handy stuff in there. :wink:

:idea: Next time you need to do something like this and aren't sure if there is something built in or not, I've found something I think is pretty handy. Bring up the Online Help in the Designer and switch to the Index tab. Type BASIC and then arrow down to 'alphabetic list of' and hit enter. This is a nice page in-and-of itself, but wait - there's more!

You'll see a note at the top of the page saying something on the order of 'if you are unsure of what you need, see BASIC Tasks. You can also get there right from the Index. Lots of good functions listed by task type. Wouldn't have (directly) solved your digits problem, but a good resource.

You should also check out all of the various Conversion Codes available for the Iconv/Oconv functions. It's amazing how many things other than dates that you can 'conv' with them. :lol: