CFLib.org – Common Function Library Project

ListDeleteLeft(list, numElements[, delimiter])

Last updated April 24, 2002

author

Shaun Ambrose

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;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson