View previous topic :: View next topic
|
Author |
Message |
cigarman
New User
Joined: 19 May 2007 Posts: 25 Location: Chicago
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Take a look at the TRANSLATE command, but if not, a nice little edit macro should do the job. |
|
Back to top |
|
|
cigarman
New User
Joined: 19 May 2007 Posts: 25 Location: Chicago
|
|
|
|
I saw the translate function. That looks like single character only. Me thinks a macro is in order... |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
As alternatives, depending on the circumstances, there's always regular (TSO) EDIT, and IPOUPDTE. |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
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 |
|
|
cigarman
New User
Joined: 19 May 2007 Posts: 25 Location: Chicago
|
|
|
|
Totally cool.
Thank you sir. |
|
Back to top |
|
|
|