Link to home
Start Free TrialLog in
Avatar of ondrejko1
ondrejko1

asked on

ColdFusion limiting text and words without cutting words in half?

Let's say we have a fixed area to display words or text and we do not simply want to truncate based on the number of characters because we do not want words to get cut in half.

We could do
How to design and install a brick or pavers walkw...

Ideally, we would want
How to design and install a brick or pavers...

Anyone know of a quick and simple way to do this.  I know how to
<CFSET desctrunc = LEFT(description,34)> but obviously that is based on characters.

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of SidFishes
SidFishes
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No points. SidFishes already gave you the answer.

Definitely check out the string library. at cflib.org .  In addition to fullLeft(), they have a bunch of functions for stuff like this:

http://www.cflib.org/library/StrLib
Avatar of ondrejko1
ondrejko1

ASKER

it throws the following error when trying to use in a CFC

Unable to complete CFML to Java translation. Error information unsupported statement: class coldfusion.compiler.ASTfunctionDefinition <br>The error occurred on line 4387.