-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> I want to find the position of the last occurence
> of / in a string and save it to a variable so here
> is what I am doing.
>
> <CFSET lastslash Find(/, #string_name#, #len(string_name)#>
>
> I have two problems. It doesn't like the / so I am
> assuming I need an escape charachter which I can't find.
Nope. Try some quotes... (And get rid of all those extra pound
signs!)
> The second is I want to start from the end and work
> my way back. It looks like Find and FindNoCase all
> only go from left to right and i want to go right to
> left.
Now... I would have bet money there was a FindLast or ReverseFind or
something in CF, but I can't find it in my quickref booklet. Must be
thinking of ASP or something...
This should do the trick:
<cfset LastSlash = (Len(string_name) - FindNoCase("/",
Reverse(string_name))) + 1>
Tho this would probably be marginally more efficient:
<cfloop from="#Len(String_Name)#" to="1" step="-1" index="i">
<cfif Mid(String_Name, i, 1) EQ "/">
<cfset LastSlash = i>
<cfbreak>
</cfif>
</cfloop>
Or Even:
<cfscript>
for(i=Len(String_Name);i GT 0;i=i+1) {
if(Mid(String_Name), i, 1) EQ "/") {
LastSlash = i;
break;
}
}
</cfscript>
Best regards,
Zac Bedell
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.3 for non-commercial use <http://www.pgp.com>
Comment: Please use PGP!!!
iQA/AwUBOZxSDgraVoMWBwRBEQKQpwCeIAlXjhdpF+SCOvKjJWwQRcOjB+cAnjtk
BWOZiAP49Cc2Oef1UH6qHfUc
=Pqi1
-----END PGP SIGNATURE-----
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.