I know you already have a working example, but here's another idea..
Since Coldfusion is built on Java you can use any java function,
including the string function lastIndexOf()..

<cfset str = "here you go, here you go, here you go, here you go" />
<cfset jstr = CreateObject( "java", "java.lang.String" ).Init(str) />
<cfset intLastIndex = jstr.LastIndexOf(JavaCast( "string", "go" )) />
<cfoutput>#intLastIndex# : #len(str)#</cfoutput>

The last occurrence of "go" occurs at the 48 character

On Fri, Jul 18, 2008 at 12:21 PM, Steve Johnson <[EMAIL PROTECTED]> wrote:
> I took me a while to figure out how to utilize this, but got it working. I 
> took eleven lines of code down to seven and did not need a loop. Both 
> solutions work well, but I understand the idea of a loop slowing things down 
> due to a long string. The strings I am searching have the potential to be 
> extremely long.
>
> Thank you both for your help.
>
>> If you have a really, really long string then you could have a problem.
>> I suggest you look at Reverse() if this is the case. You can then do a
>> Find() on the reversed string which will return the first instance
>> (which is the last of your normal string)
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:3849
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to