there's almost certainly a more eloquent solution, but you can loop
from 1 to 10 using the space as a delimiter.
<cfset mystring = "the quick brown fox jumped over the lazy dog the
quick brown fox jumped over the lazy dog" />
<cfset myTruncatedString = "" />
<cfloop list="#myString#" delimiters=" " index="i">
<cfset myTruncatedString = listAppend(myTruncatedString, i, ' ') />
<cfif i EQ 10><cfbreak /></cfif>
</cfloop>
<cfoutput>#myTruncatedString#</cfoutput>
On 11/23/05, Nomad <[EMAIL PROTECTED]> wrote:
> Hello!
> Need help.
>
> How do I get the first (say 10) words from a string?
> Problem:
>
> A query to my database returns a column (details) that is of memo type. I
> want to limit the display of this column to the first 10 words only.
> I had a quick look at the CFML documentation for string functions but could
> not find any that works with words (not characters).
> I am obviously missing something. What is it?
>
> Thanks a lot.
>
> Ben
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:225131
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54