CFLib.org – Common Function Library Project

ListRestRight(orgList[, listDel])

Last updated December 07, 2009

author

Antoine Gattolliat

Version: 1 | Requires: | Library: StrLib

Description:
Same functionality as CF ListRest starting from right instead of left. Based on Tom Kitta's ListRest2 that works faster than CF ListRest.

Return Values:
Returns a string.

Example:

<cfset foo = ListRestRight("1,2,3,4,5")><!--- foo = 1,2,3,4 --->
<cfset foo = ListRestRight("")><!--- foo = empty string --->
<cfset foo = ListRestRight("1")><!--- foo = empty string --->

Parameters:

Name Description Required
orgList Original list. Yes
listDel List delimiter. Defaults to a comma. No

Full UDF Source:

/**
 * Same functionality as CF ListRest starting from right instead of left.
 * 
 * @param orgList      Original list. (Required)
 * @param listDel      List delimiter. Defaults to a comma. (Optional)
 * @return Returns a string. 
 * @author Antoine Gattolliat (antoine@igloo.be) 
 * @version 1, December 6, 2009 
 */
function ListRestRight(orgList) {
    var listDel = ',';
    if(arrayLen(arguments) gte 2) listDel = arguments[2];
    if (len(orgList) gt 0) return listDeleteAt(orgList,ListLen(orgList,listDel),listDel);
    return "";
}

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

Created by Raymond Camden / Design by Justin Johnson