MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

REXX help - Find all the substrings within a string

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
vijay
Beginner


Joined: 09 May 2003
Posts: 131
Topics: 64

PostPosted: Fri Oct 14, 2011 9:16 pm    Post subject: REXX help - Find all the substrings within a string Reply with quote

Hi,
I need a rexx function with identifying all substrings in the string that start with %HLQS and end with a ',' ' ' '+' or ')'

Examples:
STR1="AFTER ( %HLQS.A.B.1,%HLQS.A.B.2,%HLQS.A.B.3 +

output would be : %HLQS.A.B.1 %HLQS.A.B.2 %HLQS.A.B.3

STR2=" %HLQS.A.B.4,%HLQS.A.B.5,%HLQS.A.B.6 +
output would be : %HLQS.A.B.4 %HLQS.A.B.5 %HLQS.A.B.6


STR3=" %HLQS.A.B.7,%HLQS.A.B.8,%HLQS.A.B.9.0)
output would be : %HLQS.A.B.7 %HLQS.A.B.8 %HLQS.A.B.9.0


Thanks,
vijay
Back to top
View user's profile Send private message
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Fri Oct 14, 2011 11:08 pm    Post subject: Reply with quote

And you posted this in multiple forums because. . . Sad

If we see this again, your posts will be deleted from the other forum(s).
Back to top
View user's profile Send private message
vijay
Beginner


Joined: 09 May 2003
Posts: 131
Topics: 64

PostPosted: Sat Oct 15, 2011 10:37 am    Post subject: Reply with quote

sorry,I did not know the rules.Do you have any suggestion/solution to this problem ?
Back to top
View user's profile Send private message
vijay
Beginner


Joined: 09 May 2003
Posts: 131
Topics: 64

PostPosted: Sat Oct 15, 2011 11:52 am    Post subject: Reply with quote

Hi , I managed to do this using translate and POS.
Thanks
Back to top
View user's profile Send private message
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Sat Oct 15, 2011 10:12 pm    Post subject: Reply with quote

Answers were given in the other forum. . .
Back to top
View user's profile Send private message
vicente
Beginner


Joined: 04 Oct 2011
Posts: 1
Topics: 0
Location: SPAIN

PostPosted: Mon Oct 17, 2011 6:46 am    Post subject: Reply with quote

s1=TRANSLATE(str1,' ',',')
s2 = TRANSLATE(s1,' ',')')
s3 = TRANSLATE(s2,' ','+')
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Fri Oct 21, 2011 12:12 am    Post subject: Reply with quote

The translate option shown does not answer the question. It doesn't check for the qualifications of the beginning or end characters. Presumably this is being written to do substitution. A better solution is a parse loop starting pulling out strings starting with % and ending with <whatever character> or better yet either a loop of either parse or pos() followed by a verify() & substr(). I'd guess it is 8-10 lines of code. lots of ways to do it though. It depends on how generalized you want to make it. I definitely would not assume the delimiters will never change or that the format will never change.
_________________
New members are encouraged to read the How To Ask Questions The Smart Way FAQ at http://www.catb.org/~esr/faqs/smart-questions.html.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group