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

Replace whole words in a string?


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Tue Jul 03, 2007 9:56 pm
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
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

Global Moderator


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

PostPosted: Wed Jul 04, 2007 12:49 am
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: 2358
Location: Israel

PostPosted: Wed Jul 04, 2007 10:53 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts replace word 'MONTH' with current mon... SYNCSORT 11
Search our Forums:

Back to Top