How about:

<cfset textVar = "This is a really wonderful, and nice chunk of text.">
<cfloop from="21" to="1" step="-1" index="CharPosition">
  <cfif Mid(textVar, CharPosition, 1) is " ">
    <cfset first20 = Left(textVar,(CharPosition - 1))>
    <cfbreak>
  </cfif>
</cfloop>
<cfoutput>#first20#</cfoutput>

David Gassner
Vintage Business Applications

> -----Original Message-----
> From: Chris Lott [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, April 08, 2000 12:58 AM
> To: [EMAIL PROTECTED]
> Subject: Left X characters without breaking a word...
>
>
> Any ideas on the most efficient way to grab the leftmost 20
> characters of a
> field, or as close as possible without going over, but without chopping a
> word in the middle? For instance, given the following text:
>
> This is a really wonderful, and nice chunk of text.
>
> I would want to break it after "Really" because taking the first 20 would
> break the text in the middle of the word "wonderful"...
>
> c
> --
> Chris Lott <[EMAIL PROTECTED]>,  Technical Manager
> p907.474.5122  |  f907.474.5402  |  PGP Key ID: 0x8687E87E
>
> ------------------------------------------------------------------
> ------------
> Archives: http://www.eGroups.com/list/cf-talk
> 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.

------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
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.

Reply via email to