IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Extracting Numeric values from a string using REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
avaneendra_linga

New User


Joined: 13 Dec 2006
Posts: 73
Location: Hyderabad

PostPosted: Thu Feb 01, 2007 10:48 am
Reply with quote

hi,
i have a string from this i have to get the numeric values only....
ex: 45 mainstreet apt 22c
from this i have to get output as 4522 in rexx...
can any body help on this......
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Thu Feb 01, 2007 11:42 am
Reply with quote

Here is my solution:
Code:
/* REXX */                                                             
                                                                       
STRING = '45 mainstreet apt 22c'                                       
                                                                       
STRING = SPACE(TRANSLATE(STRING,' ','abcdefghijklmnopqrstuvwxyz'),0)   
                                                                       
SAY STRING                                                             
                                                                       
EXIT                                                                   


O.
Back to top
View user's profile Send private message
Steve Coalbran

New User


Joined: 01 Feb 2007
Posts: 89
Location: Stockholm, Sweden

PostPosted: Sat Feb 03, 2007 3:22 pm
Reply with quote

Sounds like homework for Rexx 1-01?
Code:

SAY NUMONLY("45 mainstreet apt 22c")                   
EXIT                                                   
NUMONLY: RETURN SPACE(TRANSLATE(ARG(1),LEFT("",246),, 
XRANGE('00'X,'EF'X)XRANGE('FA'X,'FF'X)),0)             
SAY NUMONLY("45 mainstreet apt 22c")                   

gives
Code:
4522
Back to top
View user's profile Send private message
Steve Coalbran

New User


Joined: 01 Feb 2007
Posts: 89
Location: Stockholm, Sweden

PostPosted: Sat Feb 03, 2007 3:25 pm
Reply with quote

Sorry, remove the last SAY line!
It can't be executed obviously, just my sloppy cut+paste!
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Trouble using REXX SDSF interface to ... CLIST & REXX 3
No new posts count contained values of several col... DB2 5
No new posts REXX to get all Dataset names from a ... CLIST & REXX 5
No new posts Instream REXX? JCL & VSAM 13
No new posts CEMT using Rexx? Help please CLIST & REXX 3
Search our Forums:


Back to Top