CFLib.org – Common Function Library Project

REListFindNoCaseMultiple(reg_expr, tlist[, delims])

Last updated October 19, 2004

author

Robert Munn

Version: 1 | Requires: CF5 | Library: StrLib

Description:
The function takes a given regular expression and evaluates each element of a given list of values against the regular expression. The match is case-insensitive. If the regular expression matches an element in the list, the list location of that element is added to a list of matched locations. The function returns the list of matched locations.

Return Values:
Returns a list of matches.

Example:

<cfset mylist = "Rob Munn|Robert Munn|RDM|Fred|Gregg|Rob">
<cfset myReturn = REListFindNoCaseMultiple("Rob[^\|]*",mylist,"|")>

<cfoutput>#myReturn#</cfoutput>

Parameters:

Name Description Required
reg_expr The regular expression for the search. Yes
tlist The list. Yes
delims List delimeter. Defaults to a comma. No

Full UDF Source:

/**
 * When given a list of values, returns a list of element locations that match a given regular expression.
 * 
 * @param reg_expr 	 The regular expression for the search. (Required)
 * @param tlist 	 The list. (Required)
 * @param delims 	 List delimeter. Defaults to a comma. (Optional)
 * @return Returns a list of matches. 
 * @author Robert Munn (robert.munn@alumni.tufts.edu) 
 * @version 1, October 19, 2004 
 */
function REListFindNoCaseMultiple(reg_expr,tlist){
 	var results="";
	var expr_location = 0;
	var i = 1;
	var delims = ",";
	
	if(arrayLen(arguments) gt 2) delims = arguments[3];
	
	for(; i lte listlen(tlist,delims); i=i+1){
	    expr_location = REFindNoCase(reg_expr,listgetat(tlist,i,delims));
	    if(expr_location gt 0) results=listappend(results,i);
	}    		
	return results;
}
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