Create a gist now

Instantly share code, notes, and snippets.

anonymous /cameronquiz.cfm Secret
Created Aug 12, 2016

What would you like to do?
<cfscript>
/* lucee or adobe CF 11+ */
mystrings = ['a', 'at', 'cat', 'scat', 'catch'];
mytest = '.+at';
function firstMatch( strings, regex ) {
var test = arguments.regex;
var passing = arguments.strings.filter( function ( check ) {
var matches = REMatch( test, check );
return matches.Len() > 0;
});
return passing[ 1 ];
}
WriteOutput( firstMatch( mystrings, mytest ) );
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment