-
-
Save anonymous/1fae50d39c35a17c28d1b50fac01a43b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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