0

leftWords() function for trimming strings but keeping words intact

ColdFusion

Someone posted the following on our CFUG email list today looking for a way to trim a string to 250 characters, but if that 250 fell in the middle of a word, to exclude that last word and end the string at the preceding space. I created a simple little method for doing this named leftWord(), which accepts the two arguments "InputString" and "CharacterLimit". Feel free to better-fy it all you want! :)


 

 

tags:
ColdFusion
tony petruzzi said:
 
http://www.cflib.org/udf.cfm?ID=329

why reinvent the wheel? been using it for years now.
 
posted 1017 days ago
Add Comment Reply to: this comment OR this thread
 

Search