<cfscript>
/**
* Displays n number of characters from a string without cutting off in the
middle of a word
* Code used from FullLeft
*
* @param string String to be modified. (Required)
* @param number Number of characters to include in teaser. (Required)
* @param urlArgument URL to use for 'more' link. (Optional)
* @return Returns a string.
* @author Bryan LaPlante ([EMAIL PROTECTED])
* @version 3, July 31, 2003
*/
function FormatTeaser(string,number){
var urlArgument = "";
var shortString = "";
//return quickly if string is short or no spaces at all
if(len(string) lte number or not refind("[[:space:]]",string)) return
string;
if(arrayLen(arguments) gt 2) urlArgument = "... <a href="" & arguments[3]
& """>[more]</a>";
//Full Left code (http://www.cflib.org/udf.cfm?ID=329)
if(reFind("[[:space:]]",mid(string,number+1,1))) {
shortString = left(string,number);
} else {
if(number-refind("[[:space:]]", reverse(mid(string,1,number))))
shortString = Left(string, (number-refind("[[:space:]]",
reverse(mid(string,1,number)))));
else shortString = left(str,1);
}
return shortString & urlArgument;
}
</cfscript>
----- Original Message -----
From: "Bob Haroche"
> > this will do #Left(report.maint_report_task,25)#...
>
> Out of curiosity, that will trim based on number of characters, yes?
> How would one grab the first X number of whole words. IOW trim
> characters but stop at a space. Would you need to combine that with
> some regex?
>
>
> -------------
> Regards,
> Bob Haroche
> O n P o i n t S o l u t i o n s
> www.OnPointSolutions.com
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

