CFLib.org – Common Function Library Project

removeNullAndDangleDelimFromList(lst[, delim])

Last updated March 07, 2010

author

Bharat Patel

Version: 0 | Requires: CF5 | Library: StrLib

Description:
This is the simplest way to remove null element and dangle delimiter from the given list.

Return Values:
Returns a string.

Example:

<cfset List1 = '1,2,,CF,,Oracle,Sql,,7,'>
<cfoutput>
    #List1#<br />
    #removeNullAndDangleDelimFromList(List1,',')#    
</cfoutput>

Parameters:

Name Description Required
lst list to remove null elements and dangling delimiter Yes
delim list delimiter, defaults to comma "," No

Full UDF Source:

/**
 * Remove null element and dangel delimiter from the list
 * 
 * @param lst      list to remove null elements and dangling delimiter (Required)
 * @param delim      list delimiter, defaults to comma "," (Optional)
 * @return Returns a string. 
 * @author Bharat Patel (bharat@isummation.com) 
 * @version 0, March 7, 2010 
 */
function removeNullAndDangleDelimFromList(lst){
    var listDelim=",";
    if (arraylen(arguments) gt 1)
        listDelim=arguments[2];
    return ArrayToList(ListToArray(arguments.lst,listDelim));
}

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