Page 1 of 1

Data Stage function extracting only numbers

Posted: Thu Aug 17, 2006 9:23 am
by Umbix62
I'm looking for a DataStage function that recognize and extract the numeric character from a string. For example

I have a variable with this value:

"Ab12gh3s4"

The function have to returns "1234". I can created a function to do that but before I would know if it already exists a DataStage funtion able to do this type of data extraction.

Thank you everybody

Umberto

Posted: Thu Aug 17, 2006 9:27 am
by kaps
Use MC/A function with oconv.

Posted: Thu Aug 17, 2006 9:37 am
by Umbix62
kaps wrote:Use MC/A function with oconv.
I just tried, before reading your answer, the oconv function using "MCN" as second parameter and it works well. Is it the same? Anyway thank you for you help.

Posted: Thu Aug 17, 2006 9:39 am
by DSguru2B
MCN with OCONV extracts only numbers. You can also look at the function DIGITS(). It does the exact same thing.

Posted: Thu Aug 17, 2006 9:41 am
by chulett
DIGITS is a Transform, not a function. Makes the whole 'MCN' thing easier to understand in the job. :wink:

Posted: Thu Aug 17, 2006 9:48 am
by DSguru2B
Actually thats what i meant to say, a Transform function. I dont know why i categorize everything as a 'function' :) Bound by habit i guess.

Posted: Thu Aug 17, 2006 9:56 am
by Umbix62
DSguru2B wrote:MCN with OCONV extracts only numbers. You can also look at the function DIGITS(). It does the exact same thing.
It's exactly what I want. I want to extract only digits from the input string, rejecteting all other character.

I saw the online DataStage manuals and now I know the differences between "MCN" and "MC/A". I have to use "MCN" for reformatting the input string without the alphabetic characters.

Thank you very much

Have a nice day

Umberto