View previous topic :: View next topic
|
Author |
Message |
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
Hi,
I am a beginner in REXX. I have struck with a problem.
I have a string like this "T70435.USER.TEMP.SRC" and i need to change this
"T70435.USER.TEMP.CPY". Please let me know how to do this ?
Thanks,
Sri |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Assuming that there is some reason that you cannot use an edit macro, and that the volume of data is not so great that the (lack of) performance of EXECIO is significant, use the POS (or INDEX; I prefer POS) function find the desired sub-string, and the SUBSTR function and concatenation operator to re-assemble the string after replacement. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
If the string was always something like a dataset name, I'd PARSE it into tokens and just swap the specific token with its replacement value, then concatenate the tokens back together. |
|
Back to top |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
sri_mf wrote: |
Hi,
I am a beginner in REXX. I have struck with a problem.
I have a string like this "T70435.USER.TEMP.SRC" and i need to change this
"T70435.USER.TEMP.CPY". Please let me know how to do this ?
Thanks,
Sri |
Thanks to all for the inputs.. Really usefull information to start ...
I tried a basic method.
Here is the REXX code i have coded.
Code: |
MYSTR = 'T70435.USER.TEMP.SRC'
WORD_POS=INDEX(MYSTR,'SRC')
SAY "WORD_POS:"WORD_POS
MYSTR1=OVERLAY('CPY',MYSTR,WORD_POS)
SAY "MYSTR1:"MYSTR1 |
|
|
Back to top |
|
|
parsesource
New User
Joined: 06 Feb 2006 Posts: 97
|
|
|
|
sri_mf wrote: |
Hi,
I am a beginner in REXX. I have struck with a problem.
I have a string like this "T70435.USER.TEMP.SRC" and i need to change this
"T70435.USER.TEMP.CPY". Please let me know how to do this ?
Thanks,
Sri |
not tested =>
Code: |
PARSE VALUE REVERSE(DSNAME) '.'A
NEWDSNAME=REVERSE(A)!!'.CPY'
|
|
|
Back to top |
|
|
|