Alpha numeric

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
murali
Participant
Posts: 54
Joined: Mon Sep 12, 2005 11:38 pm

Alpha numeric

Post by murali »

Hi
I need to extract only alpha numeric from the input string
for example 'as df is xx #$ 90:' is the string and i need to extract
'as df is xx 90' in the out put ,can any one help me in coding this.
Thanks in advance
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Look at the OCONV function in your DS BASIC manual, the token MCP removes unprintable characters. There's other options to remove not letters and numeric values. You could also use EREPLACE, CHANGE, and CONVERT to name the specific values to be replaced or removed.
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
murali
Participant
Posts: 54
Joined: Mon Sep 12, 2005 11:38 pm

Post by murali »

Hi kcbland
i have used the oconv function and MCP as token i did not get the result
can u pls code it and show me ,amy be my syantax was wrong
thankyou
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You might want to try using the LETTERS transform that is available under the Built-in/String category. Handles the syntax for you.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sun rays
Charter Member
Charter Member
Posts: 57
Joined: Wed Jun 08, 2005 3:35 pm
Location: Denver, CO

Post by sun rays »

chulett wrote:You might want to try using the LETTERS transform that is available under the Built-in/String category. Handles the syntax for you.
LETTERS Transform would stip off the numeric characters too.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The 'MCA' conversion will return just the alphabetic part, the 'MCN' will do just the numeric but there is no conversion for alphanumeric only. I can do a MATCHES on that pattern, but couldn't get a way to have that answer returned.

You could use the following routine I just clobbered together:

ReturnAlphanumeric(Arg1)

Code: Select all

WorkString = UPCASE(Arg1) ;** makes comparison easier
StringLen  = LEN(WorkString)
Ans        = ''
FOR Index = 1 TO StringLen
   TestChar = WorkString[Index,1]
   IF TestChar < 'A' OR TestChar > 'Z'
   THEN
      IF TestChar = ' ' OR (TestChar => '0' AND TestChar <= '9') THEN Ans := Arg1[Index,1]
   END
   ELSE Ans := Arg1[Index,1]
NEXT I
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

If you put this in a function it would work great also:

Code: Select all

Ans = Arg1
CONVERT "`!@#$%^&*()_+~-=;:,./<>?\|'" TO "" IN Ans
CONVERT '"' TO "" IN Ans
I hope you get the idea. :D
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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

sun rays wrote:
chulett wrote:You might want to try using the LETTERS transform that is available under the Built-in/String category. Handles the syntax for you.
LETTERS Transform would stip off the numeric characters too.
True. Missed the 'numeric' part of the 'alpha numeric' question... doh! :oops:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I though about doing the CONVERT, especially since it is more efficient than a user-written routine; but thought that it might contain more than just the standard non-alphanumeric characters. If the poster knows what characters might be in the data then a CONVERT is better, if it might be any string then the posted code, or possibly a CONVERT in combination with a conversion using 'MCP'.
Post Reply