listTrim(ThisList[, ThisDelimiter])
Last updated May 08, 2006
Version: 1 | Requires: CF5 | Library: StrLib
Description:
ListTrim accepts a list and an optional delimiter value (defaults to comma if not passed), and then returns the same list of trimmed values.
Return Values:
Returns a string.
Example:
<cfset origList = "ray, jacob, lynn, noah, luke, anakin, walt, 4, 8, 15, 16, 23, 42">
<cfoutput>#listTrim(origList)#</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
ThisList | List to trim. | Yes |
ThisDelimiter | List delimiter. Defaults to a comma. | No |
Full UDF Source:
/**
* Returns the list which was passed in after having trimmed each list item.
*
* @param ThisList List to trim. (Required)
* @param ThisDelimiter List delimiter. Defaults to a comma. (Optional)
* @return Returns a string.
* @author Christopher Jordan (cjordan@placs.net)
* @version 1, May 8, 2006
*/
function listTrim(ThisList) {
var i = 0;
var ThisDelimiter = ",";
var ThisListItem = "";
var ThisTrimmedList = "";
// check for passed delimiter
if(ArrayLen(Arguments) EQ 2){
ThisDelimiter = Arguments[2];
}
for(i = 1; i LTE ListLen(ThisList,ThisDelimiter); i = i + 1){
ThisListItem = Trim(ListGetAt(ThisList,i,ThisDelimiter));
ThisTrimmedList = ListAppend(ThisTrimmedList,ThisListItem,ThisDelimiter);
}
return ThisTrimmedList;
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016