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
No new posts Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am
No new posts To display values of multiple rows in... vinu78 DB2 2 Thu Mar 09, 2017 1:20 pm
No new posts REXX cdoe to purge a JOB from spool a... Sulabh Agrawal CLIST & REXX 11 Thu Mar 09, 2017 11:36 am
No new posts Overriding PS data in rexx Shaheen Shaik CLIST & REXX 8 Fri Mar 03, 2017 5:08 pm
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm


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