View previous topic :: View next topic |
Author |
Message |
vijay Beginner
Joined: 09 May 2003 Posts: 131 Topics: 64
|
Posted: Fri Oct 14, 2011 9:16 pm Post subject: REXX help - Find all the substrings within a string |
|
|
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 |
|
 |
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Fri Oct 14, 2011 11:08 pm Post subject: |
|
|
And you posted this in multiple forums because. . .
If we see this again, your posts will be deleted from the other forum(s). |
|
Back to top |
|
 |
vijay Beginner
Joined: 09 May 2003 Posts: 131 Topics: 64
|
Posted: Sat Oct 15, 2011 10:37 am Post subject: |
|
|
sorry,I did not know the rules.Do you have any suggestion/solution to this problem ? |
|
Back to top |
|
 |
vijay Beginner
Joined: 09 May 2003 Posts: 131 Topics: 64
|
Posted: Sat Oct 15, 2011 11:52 am Post subject: |
|
|
Hi , I managed to do this using translate and POS.
Thanks |
|
Back to top |
|
 |
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Sat Oct 15, 2011 10:12 pm Post subject: |
|
|
Answers were given in the other forum. . . |
|
Back to top |
|
 |
vicente Beginner
Joined: 04 Oct 2011 Posts: 1 Topics: 0 Location: SPAIN
|
Posted: Mon Oct 17, 2011 6:46 am Post subject: |
|
|
s1=TRANSLATE(str1,' ',',')
s2 = TRANSLATE(s1,' ',')')
s3 = TRANSLATE(s2,' ','+') |
|
Back to top |
|
 |
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Fri Oct 21, 2011 12:12 am Post subject: |
|
|
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 |
|
 |
|
|