CFLib.org – Common Function Library Project

justNumericList(nList[, strDelim])

Last updated April 01, 2010

author

Raymond Camden

Version: 2 | Requires: CF5 | Library: StrLib

Description:
Filters a list so that just numeric entries are returned. Based on isNumericList by John Rice.

Return Values:
Returns a string.

Example:

<cfset l = "3,4,6,2,d,4,2,gg,2,1,qqwqw,21,12,gg">
<cfset fl = justNumericList(l)>
<cfoutput>#fl#</cfoutput>

Parameters:

Name Description Required
nList List to filter. Yes
strDelim List delimiter. Defaults to a comma. No

Full UDF Source:

/**
 * Filters a list so that just numeric entries are returned.
 * v2 changes by James Moberg
 * 
 * @param nList      List to filter. (Required)
 * @param strDelim      List delimiter. Defaults to a comma. (Optional)
 * @return Returns a string. 
 * @author Raymond Camden (ray@camdenfamily.com) 
 * @version 2, April 1, 2010 
 */
function justNumericList(nList) {
   var intIndex = 0;
   var aryN = arrayNew(1);
   var strDelim = ",";
   var result = arrayNew(1);
   if (arrayLen(arguments) gte 2) strDelim = arguments[2];
   aryN = listToArray(nlist,strDelim);
   for (intIndex=1;intIndex LTE arrayLen(aryN);intIndex=intIndex+1) {
    if (not compare(val(aryN[intIndex]),aryN[intIndex])) arrayAppend(result, aryN[intIndex]);
   }
   return arrayToList(result,strDelim);
}

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