Created
March 29, 2012 13:34
ColdFusion 10 - reEscape() vs. Java Pattern's Quote() Method
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> | |
// Escape a string with ColdFusion 10's new reEscape() method. | |
// This escapes all the special control characters in the string. | |
// | |
// NOTE: This escape sequence can be used in BOTH a ColdFusion | |
// and a Java regular expression pattern. | |
writeOutput( | |
"reEscape: " & | |
reEscape( | |
"[who's] Johnny, she said (and smiled in her special way)." | |
) | |
); | |
writeOutput( "<br />" ); | |
// Escape a string using Java Pattern's quote() function. This | |
// escapes all the special control characters in the string. | |
// | |
// NOTE: This escape sequence can ONLY BE USED in a Java regular | |
// expression pattern. | |
writeOutput( | |
"Quote: " & | |
createObject( "java", "java.util.regex.Pattern" ).quote( | |
"[who's] Johnny, she said (and smiled in her special way)." | |
) | |
); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment