[Top] [All Lists]

Re: Splitting a text string

Subject: Re: Splitting a text string
From: Ian Skinner
Date: Mon, 17 Nov 2008 14:16:19 -0800
Newsgroups: macromedia.coldfusion.advanced_techniques

Questions you are going to have to answer for your self.

What constitutes a word? Spaces, Dashes, Punctuation?

What constitutes 'about' 400 chars?
   As close as possible but under?
   First word that goes over?
   The closest either over or under?

But you should be able to get somewhere if you treat your string as a list with spaces and|or other characters as delimiters. Real basic starter code, completely untried and untested.
<cfset string = "The quick brown fox jumped over the lazy dog">

<cfset subString = "">
<cfloop list="#string#" index="word">
  <cfset subString = subString + word>
  <cfif len(subString) GT 10>
    <cfset subString = "">

<Prev in Thread] Current Thread [Next in Thread>