Skip to content

Instantly share code, notes, and snippets.

/cameronquiz.cfm Secret

Created August 12, 2016 14:39
Show Gist options
  • Save anonymous/1fae50d39c35a17c28d1b50fac01a43b to your computer and use it in GitHub Desktop.
Save anonymous/1fae50d39c35a17c28d1b50fac01a43b to your computer and use it in GitHub Desktop.
<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