CFLib.org – Common Function Library Project

ListReFindNoCase(list, regexp[, delimiter])

Last updated May 26, 2003

author

Tony Kenny

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Searches a given list for a given regexp and returns the index number of the first item it finds in the list that matches the regexp. Returns 0 (zero) if not found.

Return Values:
Returns a number.

Example:

<cfset mylist = "this,that,other,thing">
<cfoutput>#ListReFindNoCase(mylist, ".th")#
</cfoutput>

Parameters:

Name Description Required
list The list to search. Yes
regexp The regular expression to use. Yes
delimiter The list delimiter, defaults to a comma. No

Full UDF Source:

/**
 * Searches a given list for a given regexp and returns the index number of the first item found.
 * 
 * @param list 	 The list to search. (Required)
 * @param regexp 	 The regular expression to use. (Required)
 * @param delimiter 	 The list delimiter, defaults to a comma. (Optional)
 * @return Returns a number. 
 * @author Tony Kenny (tony@kenny.net) 
 * @version 1, May 26, 2003 
 */
function ListReFindNoCase(list, regexp) {
	var i = 1;
	var delimiter = ",";
	
	if(arrayLen(arguments) gte 3) delimiter = arguments[3];

	for (i=1; i le listLen(list, delimiter); i=i+1) {
		if ( ReFindNoCase(regexp, listGetAt(list, i, delimiter)) ) 	return i;
	}
	
	return 0;
}
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