Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to replace a word in a string ?

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

Active User


Joined: 31 Aug 2006
Posts: 215
Location: India

PostPosted: Mon Jan 10, 2011 10:46 pm    Post subject: How to replace a word in a string ?
Reply with quote

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
View user's profile Send private message

Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1777
Location: Bloomington, IL

PostPosted: Mon Jan 10, 2011 10:59 pm    Post subject:
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10327
Location: italy

PostPosted: Mon Jan 10, 2011 11:00 pm    Post subject: Reply to: How to replace a word in a string ?
Reply with quote

all depends....
fixed position, fixed length,
any position any length, one/many occurrence,
OVERLAY,POS,SUBSTR,LENGTH, || ( concatenation) are the REXX functions operators that would be used for such a task



z/OS V1R2.0-V1R10.0 TSO/E REXX User's Guide
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IKJ4C310/CCONTENTS?SHELF=IKJ4BK90&DN=SA22-7791-01&DT=20010706113306

z/OS V1R8.0-V1R10.0 TSO/E REXX Reference
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IKJ4A370/CCONTENTS?SHELF=IKJ4BK90&DN=SA22-7790-07&DT=20060626210253
Back to top
View user's profile Send private message
superk

Moderator Team Head


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

PostPosted: Tue Jan 11, 2011 1:00 am    Post subject: Reply to: How to replace a word in a string ?
Reply with quote

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
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 215
Location: India

PostPosted: Tue Jan 11, 2011 1:24 pm    Post subject: Re: How to replace a word in a string ?
Reply with quote

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
View user's profile Send private message
parsesource

New User


Joined: 06 Feb 2006
Posts: 97

PostPosted: Mon Jan 17, 2011 3:13 am    Post subject: Re: How to replace a word in a string ?
Reply with quote

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
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 line 52: Name or string > 250 char... Ashishpanpaliya CLIST & REXX 5 Sat Oct 14, 2017 2:29 am
No new posts Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm
No new posts How to change a string containing the... chong.zhou TSO/ISPF 6 Tue Aug 29, 2017 4:54 pm
No new posts String after '.' (period) is not copy... balaji81_k SYNCSORT 6 Wed Aug 23, 2017 9:35 pm
No new posts change string before sertan string anatol DFSORT/ICETOOL 8 Tue Aug 15, 2017 5:43 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us