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 REXX to view the PGM or PROC jackzhang75 CLIST & REXX 11 Tue Jun 20, 2017 1:20 am
No new posts Validate if a Value from the file is ... balacsv2 COBOL Programming 8 Mon Jun 19, 2017 11:52 pm
No new posts Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
This topic is locked: you cannot edit posts or make replies. Need help on If condition continuatio... ashok_uddaraju CLIST & REXX 4 Fri May 19, 2017 8:55 am
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm


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