That's just perfect! 
 
Thanks

   _____  

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Dave Shuck
Sent: Thursday, January 25, 2007 10:00 AM
To: Dallas/Fort Worth ColdFusion User Group Mailing List
Subject: Re: [DFW CFUG] trimming a string to so many words


Just a first swag, but how about something like....

<cfset MyString = "your big giant string" />
<cfset CharCount = 0 />
<cfset NewString = "" />
<cfloop list=#MyString# index="i" delimiters=" "> 
    <cfif CharCount + Len(i) LTE 250>
        <cfset CharCount = CharCount + Len(i) />
        <cfset NewString = ListAppend(NewString,i," ") />
    <cfelse>
        <cfbreak /> 
    </cfif>
</cfloop>




On 1/25/07, Colin Wilson <HYPERLINK
"mailto:[EMAIL PROTECTED]"[EMAIL PROTECTED]> wrote: 

Looking for a suggested resource where I might find how to trim a string to
a certain length, but not chop the words..
 
such that it would be say 250characters, but then go back to the last space.

 
I was thinking of just a rtrim, but wasn't sure if there was a better way?
 
Thanks
 
Colin



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.10/651 - Release Date: 1/24/2007
6:48 PM



_______________________________________________
Reply to DFWCFUG:
 HYPERLINK "mailto:[email protected]"[email protected]
Subscribe/Unsubscribe: 
 HYPERLINK "http://lists1.safesecureweb.com/mailman/listinfo/list";
\nhttp://lists1.safesecureweb.com/mailman/listinfo/list
List Archives:
    HYPERLINK "http://www.mail-archive.com/list%40list.dfwcfug.org/";
\nhttp://www.mail-archive.com/list%40list.dfwcfug.org/
 HYPERLINK "http://www.mail-archive.com/list%40dfwcfug.org/"; \n
http://www.mail-archive.com/list%40dfwcfug.org/
DFWCFUG Sponsors:
 HYPERLINK "http://www.HostMySite.com"; \nwww.HostMySite.com
 HYPERLINK "http://www.teksystems.com/"; \n www.teksystems.com/







-- 
~Dave Shuck
HYPERLINK "mailto:[EMAIL PROTECTED]"[EMAIL PROTECTED]
HYPERLINK "http://www.daveshuck.com"www.daveshuck.com

Where's your Spot? 
HYPERLINK "http://www.instantspot.com"www.instantspot.com 


--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.10/651 - Release Date: 1/24/2007
6:48 PM



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.10/651 - Release Date: 1/24/2007
6:48 PM
 
_______________________________________________
Reply to DFWCFUG: 
  [email protected]
Subscribe/Unsubscribe: 
  http://lists1.safesecureweb.com/mailman/listinfo/list
List Archives: 
    http://www.mail-archive.com/list%40list.dfwcfug.org/             
  http://www.mail-archive.com/list%40dfwcfug.org/
DFWCFUG Sponsors: 
  www.HostMySite.com 
  www.teksystems.com/

Reply via email to