CFLib.org – Common Function Library Project

justNumericList(nList[, strDelim])

Last updated April 1, 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);
}
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