Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.



Read-Only Read-Only Topic
Go
Search
Notify
Tools
substring and posit
 Login/Join
 
Platinum Member
posted
We need to find a value within a substring, so we're using posit. Our problem is we need to find the last occurence of the value within the substring and posit only finds the first occurence ... is there a simple way to do this?

For example our string we're looking for is le in the statement "middle length". We want to find the position of length.

Thanks.
 
Posts: 179 | Registered: November 10, 2004Report This Post
Platinum Member
posted Hide Post
another note: we actually want to search from the end instead of the beginning.
 
Posts: 179 | Registered: November 10, 2004Report This Post
Guru
posted Hide Post
Here is two ways you can do it:

-SET &PINDX = 0;<br />-* Past Index.
<br />-SET &INDX  = 1;<br />-* Curent Index.
<br />-SET &SINDX = 1;<br />-* Start Index.
<br />-SET &EINDX = 5;<br />-* End Index.
<br />-SET &STR   = 'A';<br />-* Search String.
<br /><br />-* Thing report only needs the variable &STR.
<br />TABLE FILE CAR<br />PRINT
<br />  COUNTRY<br />COMPUTE
<br />  TEST00/A10 = LJUST(10,(REVERSE(10,(SUBSTR(10,(LJUST(10,(REVERSE(10,COUNTRY,
<br />    'A10')),'A10')),1,(POSIT((LJUST(10,(REVERSE(10,COUNTRY,'A10')),'A10')),10,
<br />    '&STR',1,'I3'))-1,10,'A10')),'A10')),'A10');
<br />-* you could use YRTNUOC and TEST01 to produce the same thing as TEST00.
<br />COMPUTE<br />  YRTNUOC/A10 = LJUST(10,(REVERSE(10,COUNTRY,'A10')),'A10'); NOPRINT
<br />COMPUTE<br />  TEST01/A10 = LJUST(10,(REVERSE(10,(SUBSTR(10,YRTNUOC,1,(POSIT(YRTNUOC,
<br />    10,'&STR',1,'I3'))-1,10,'A10')),'A10')),'A10');
<br />END
<br />-RUN<br />
<br />-* This report needs the variables &PINDX, &INDX, &SINDX, &EINDX and &STR.
<br />TABLE FILE CAR
<br />PRINT
<br />COUNTRY
<br />COMPUTE
<br />  CNTRY&PINDX/A10 = LJUST(10,COUNTRY,'A10'); NOPRINT
<br />-REPEAT :LOOP FOR &INDX FROM &SINDX TO &EINDX<br />COMPUTE
<br />  CNTRY&INDX/A10 = SUBSTR(10,CNTRY&PINDX,
<br />    (POSIT(CNTRY&PINDX,10,'&STR',1,'I3'))+1,10,10,CNTRY&INDX); NOPRINT
<br />-SET &PINDX = &INDX -1;
<br />-:LOOP
<br />-SET &INDX = &EINDX+1;
<br />COMPUTE
<br />  CNTRY&INDX/A10 = CNTRY&EINDX;
<br />END
<br />-RUN

This message has been edited. Last edited by: <Maryellen>,
 
Posts: 406 | Location: Canada | Registered: May 31, 2004Report This Post
Virtuoso
posted Hide Post
We had a discussion like this earlier in the year on Focal Point. Do a search for the keyword REVERSE.

There were a number of suggestions on how to find the last instance of a value. The solution I recommended was to use the REVERSE function to reverse the string and then do a search for the value. In your case since you are looking for 'le' do not forget to reverse the value you are looking for ('el') since the string you will be searching will be reversed. After you reverse the string, use POSIT to find 'el' instead of 'le'. After reversing the string, the first instance will really be the last and the last shall be the first. (Hmmm, where have i heard that before?)

I hope this helps.
 
Posts: 995 | Location: Gaithersburg, MD, USA | Registered: May 07, 2003Report This Post
Platinum Member
posted Hide Post
I searched for reverse but I couldn't find anything on the topic. Just knowing the keyword reverse may help.
 
Posts: 179 | Registered: November 10, 2004Report This Post
Virtuoso
posted Hide Post
I am on three discussion forums for IBI products. The discussion could have occured on another one of those forums. Sorry about that.
 
Posts: 995 | Location: Gaithersburg, MD, USA | Registered: May 07, 2003Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders