CFLib.org – Common Function Library Project

listIsItemSimilar(listIn, strToMatch[, delimeter])

Last updated January 6, 2009

author

Tony Felice

Version: 2 | Requires: CF5 | Library: StrLib

Description:
Determines whether any list items begin with the strToMatch.

Return Values:
Returns a boolean.

Example:

<cfoutput>#listIsItemSimilar("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. Yes
delimeter List delimiter. Defaults to a comma. No

Full UDF Source:

/**
 * Determines whether any list items begin with the strToMatch.
 * v2 by RCamden
 * 
 * @param listIn 	 List of values. (Required)
 * @param strToMatch 	 String to search for in the beginning of each list item. (Required)
 * @param delimeter 	 List delimiter. Defaults to a comma. (Optional)
 * @return Returns a boolean. 
 * @author Tony Felice (sites@breckcomm.com) 
 * @version 2, January 6, 2009 
 */
function listIsItemSimilar(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){
		if(findNoCase(strToMatch,left(listGetAt(listIn,xz,delim),len(strToMatch)))) return true;							
	}
	return false;
}
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