Well, the reason for the alternative approach is that he didn't specify why
he wanted to truncate the description. Typically, this is due to layout and
not necessarily content. Also, counting words breaks down as soon as you
introduce html into the mix, because it is very easy to lop off closing
tags, screwing up the display. However, if you can guarantee that there is
no html used, here is a link to an old article that Ray did that uses regex
to dump all words into an array.
http://www.raymondcamden.com/2007/08/02/Counting-Word-Instances-in-a-String.
You could then loop over this array, adding the length of each word to a
total length  variable, and outputting the word as long as the total length
variable does not exceed the maximum length limit that you set.

On Mon, Mar 9, 2015 at 1:47 PM, Michael Grant <mgr...@modus.bz> wrote:

>
> I think the point is that he's trying to truncate the text in a meaningful
> way, such as at the end of a sentence.
> One way around "4.5 houses" is to only use a period as a delimiter if it is
> followed by at least one space and an uppercase letter. It's not perfect of
> course, but it would eliminate more edge cases of your truncation not
> working as intended.
>
> Mike
>
> On Mon, Mar 9, 2015 at 1:04 PM, Dean Lawrence <dean...@gmail.com> wrote:
>
> >
> > Another option would be to place the entire description in a div and then
> > truncate it via css.
> >
> > http://www.w3schools.com/cssref/css3_pr_text-overflow.asp
> >
>



-- 

  [image: profile picture]  *Dean Lawrence*
*President*
Internet Data Technology
*Phone:* 888-438-4381 x701
*Web:* www.idatatech.com
*Email:* d...@idatatech.com
  Programming | Database | Consulting | Training


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360233
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to