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
 

 

Replace whole words in a string?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
cigarman

New User


Joined: 19 May 2007
Posts: 25
Location: Chicago

PostPosted: Tue Jul 03, 2007 9:38 pm    Post subject: Replace whole words in a string?
Reply with quote

Is there a rexx function to replace whole words in a string. I'm processing a pds member that has INCLUDE statements with OS symbols. I need to replace the characters "&SYSNAME" with "MVSA" in the string "SYS1.LIB.&SYSNAME"

I've looked at the available functions on the MF, but don't see any. Just wondering if anyone has solved this before I go and write something.
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Jul 03, 2007 9:56 pm    Post subject:
Reply with quote

Take a look at the TRANSLATE command, but if not, a nice little edit macro should do the job.
Back to top
View user's profile Send private message
cigarman

New User


Joined: 19 May 2007
Posts: 25
Location: Chicago

PostPosted: Tue Jul 03, 2007 10:22 pm    Post subject: Re: Replace whole words in a string?
Reply with quote

I saw the translate function. That looks like single character only. Me thinks a macro is in order...
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Wed Jul 04, 2007 12:49 am    Post subject: Re: Replace whole words in a string?
Reply with quote

As alternatives, depending on the circumstances, there's always regular (TSO) EDIT, and IPOUPDTE.
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Wed Jul 04, 2007 10:53 am    Post subject:
Reply with quote

ISPF Edit-Macro will do the best job, however here is a little REPLACE function:
Code:
/* REXX */                                                           
                                                                     
A = 'MY NAME IS KIKI '                                               
SAY A                                                               
B = REPLACE(A,' KIKI',' KUKU')                                       
SAY B                                                               
                                                                     
EXIT                                                                 
                                                                     
REPLACE:                                                             
                                                                     
RETSTRING  = ARG(1)                                                 
ARG2LENGTH = LENGTH(ARG(2))                                         
                                                                     
DO FOREVER                                                           
  LOOK4_POS = POS(ARG(2),RETSTRING)                                 
  IF SUBSTR(RETSTRING,LOOK4_POS+ARG2LENGTH,1) ?= ' ' THEN LEAVE     
  IF LOOK4_POS = 0 THEN LEAVE                                       
  RETSTRING  = SUBSTR(RETSTRING,1,LOOK4_POS-1)||,                   
               ARG(3)||,                                             
               SUBSTR(RETSTRING,LOOK4_POS+ARG2LENGTH)               
END                                                                 
                                                                     
RETURN RETSTRING                                                     
                                                                     


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

New User


Joined: 19 May 2007
Posts: 25
Location: Chicago

PostPosted: Fri Jul 06, 2007 2:07 am    Post subject: Re: Replace whole words in a string?
Reply with quote

Totally cool.

Thank you sir.
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 Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
This topic is locked: you cannot edit posts or make replies. Sort card to replace text using cross... Susanta SYNCSORT 32 Tue Sep 13, 2016 4:17 pm
No new posts Replace function abdulrafi COBOL Programming 13 Mon Sep 12, 2016 10:12 am
No new posts Random Password (in string format) ge... ezhavendhan COBOL Programming 10 Mon Aug 29, 2016 3:18 pm


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