CFLib.org – Common Function Library Project

listCountItemSimilar(listIn[, strToMatch][, delimeter])

Last updated January 6, 2009

author

Tony Felice

Version: 2 | Requires: CF5 | Library: StrLib

Description:
Determines number of list items that begin with the strToMatch.

Return Values:
Returns a number.

Example:

<cfoutput>#listCountItemSimilar("this,that,the other","th")#</cfoutput>

Parameters:

Name Description Required
listIn List of values. Yes
strToMatch String to search for in the beginning of each list item. No
delimeter List delimiter. Defaults to a comma. No

Full UDF Source:

/**
 * Determines number of list items that begin with the strToMatch.
 * v2 edits by RCamden
 * 
 * @param listIn 	 List of values. (Required)
 * @param strToMatch 	 String to search for in the beginning of each list item. (Optional)
 * @param delimeter 	 List delimiter. Defaults to a comma. (Optional)
 * @return Returns a number. 
 * @author Tony Felice (sites@breckcomm.com) 
 * @version 2, January 6, 2009 
 */
function listCountItemSimilar(listIn,strToMatch){
	var delim = ",";
	var count = 0;
	var xz = "";
	
	if(arrayLen(arguments) gt 2) delim = arguments[3];
	for(xz=1;xz<=listLen(listIn,delim);xz=xz+1) {
		count = count + findNoCase(strToMatch,left(listGetAt(listIn,xz,delim),len(strToMatch)));									
	}
	return count;
}
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