Last active
September 13, 2024 00:13
-
-
Save JamoCA/3f5f041f2ca5bc0a5358597a5d78c91f to your computer and use it in GitHub Desktop.
streamFind UDF (2015-06-09) Searches the output buffer to determine if a string exists. Works w/Adobe ColdFusion, Railo & Lucee. #cfml
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
<!--- streamFind UDF (2015-06-09) Searches the output buffer to determine if a string exists. Works w/Adobe ColdFusion, Railo & Lucee CFML. | |
GIST: https://gist.github.com/JamoCA/3f5f041f2ca5bc0a5358597a5d78c91f | |
BLOG: https://groups.google.com/g/railo/c/Q4KV0yT7oGk/m/hgLXXMOWtBgJ | |
TWEET: https://x.com/gamesover/status/1834384722614780095 | |
INSPIRATION: Michael Offner/Railo back in 2012. https://groups.google.com/g/railo/c/Q4KV0yT7oGk/m/hgLXXMOWtBgJ | |
---> | |
<cfscript> | |
boolean function streamFind(required string str, boolean caseSensitive=false) output=true hint="I search the output buffer to determine if a string exists" { | |
if (arguments.caseSensitive){ | |
return (listfindnocase("railo,lucee", server.ColdFusion.ProductName)) ? getPageContext().getOut().getString().indexOf(arguments.str) neq -1 : getPageContext().getCFOutput().getBuffer().toString().indexOf(arguments.str) neq -1; | |
} | |
return (listfindnocase("railo,lucee", server.ColdFusion.ProductName)) ? getPageContext().getOut().getString().toLowerCase().indexOf(lcase(arguments.str)) neq -1 : getPageContext().getCFOutput().getBuffer().findStringNoCase(arguments.str) neq -1; | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment