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;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson