ListDeleteLeft(list, numElements[, delimiter])
Last updated April 24, 2002
Version: 1 | Requires: CF5 | Library: StrLib
Description:
Deletes the n leftmost elements from the specified list. Accepts an optional delimiter. Note that if the number of elements to delete is greater than the number of elements in the list, the UDF returns an empty string.
Return Values:
Returns a string.
Example:
<cfset list="a,b,c,d,e,f,g">
<cfoutput>
#ListDeleteLeft(list, 3)#
</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
list | The list to modify. | Yes |
numElements | The number of elements to delete from the left hand side. | Yes |
delimiter | The delimiter to use. Defaults to a comma. | No |
Full UDF Source:
/**
* Deletes the n leftmost elements from the specified list.
* Modified by RCamden
*
* @param list The list to modify.
* @param numElements The number of elements to delete from the left hand side.
* @param delimiter The delimiter to use. Defaults to a comma.
* @return Returns a string.
* @author Shaun Ambrose (shaun.ambrose@arcorsys.com)
* @version 1, April 24, 2002
*/
function ListDeleteLeft(list, numElements) {
var i=0;
var delimiter=",";
if (Arraylen(arguments) gt 2) {
delimiter=arguments[3];
}
if (numElements gt ListLen(list, delimiter)) return "";
for (i=1; i lte numElements; i=i+1) {
list=listDeleteAt(list, 1, delimiter);
}
return list;
}
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