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

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