Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Extracting Numeric values from a string using REXX

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: Extracting Numeric values from a string using REXX
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: 2360
Location: Israel

PostPosted: Thu Feb 01, 2007 11:42 am    Post subject:
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: 85
Location: Stockholm, Sweden

PostPosted: Sat Feb 03, 2007 3:22 pm    Post subject: Re: Extracting Numeric values from a string using REXX
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: 85
Location: Stockholm, Sweden

PostPosted: Sat Feb 03, 2007 3:25 pm    Post subject: Re: Extracting Numeric values from a string using REXX
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Calling REXX code from ISPF panel sanchita dey TSO/ISPF 4 Mon Jan 02, 2017 5:13 pm
No new posts REXX DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 7 Fri Nov 18, 2016 1:48 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us