Filtering non alphanumeric charaters

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

Post Reply
kudaka
Premium Member
Premium Member
Posts: 37
Joined: Thu Apr 22, 2004 2:14 pm

Filtering non alphanumeric charaters

Post by kudaka »

Hello!
How to filter all non-alphanumeric charaters from a srting. (filter space,/,-,* etc).
Is there a option in oconv function for this? or any other transformation function available for this?

Input string:
'SY-002-1|SALINAS-E Boronda Rd/San'
Result:
'SY0021SALINASEBorondaRdSan'

Thank you
chucksmith
Premium Member
Premium Member
Posts: 385
Joined: Wed Jun 16, 2004 12:43 pm
Location: Virginia, USA
Contact:

Post by chucksmith »

Look at the Convert() function
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

CHANGE, EREPLACE, CONVERT
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
garthmac
Charter Member
Charter Member
Posts: 55
Joined: Tue Oct 21, 2003 9:17 am
Location: UK

Post by garthmac »

If you want to use Oconv, create your own routine using:

Ans = Oconv(Arg1, "MCA")
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:? No need to do that, there's already a built-in Transform for that - it's called LETTERS. Note that there is also what is basically the opposite called DIGITS that uses "MCN".
-craig

"You can never have too many knives" -- Logan Nine Fingers
kudaka
Premium Member
Premium Member
Posts: 37
Joined: Thu Apr 22, 2004 2:14 pm

Post by kudaka »

I used convert function. It works. But, we need to list all the unwanted characters.

FYI:
Becuase I need ALPHA and DIGITS (alpha numerics), we can not use the 'MCA' or 'MCN' formats with Oconv. Same with "LETTERS" and "DIGITS" built-in transforms.

thanks for all the help.
rasi
Participant
Posts: 464
Joined: Fri Oct 25, 2002 1:33 am
Location: Australia, Sydney

Post by rasi »

Hi

To get the non-alpha and non-numbers use the MCA and MCN function twice.

Oconv(Oconv('String','MC/N'),'MC/A')

Best of luck

Thanks
Regards
Siva

Listening to the Learned

"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

So, to keep all the alphanumerics, use that result and convert to "".

Code: Select all

Convert(Oconv(Oconv(MyString,'MC/N'),'MC/A'), "", MyString)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply