REFind and ReReplace support \r \n and \t
March 28, 2005
I noticed today that the regular expression functions in CF support the newline character \n Chr(10), carriage return \r Chr(13), and tab \t Chr(9).
Note that you can use these special character matchers inside the find pattern of ReReplace but you cannot use them in the replace expression of ReReplace.
This is probably new as of CFMX 6.0 when they moved to a Java implementation. But perhaps this has always been there, and I just never noticed it?
Here's a code example:
<cfsavecontent variable="data"> here is my break </cfsavecontent> <cfoutput>#ReReplace(data, "\n", "<br />", "ALL")#</cfoutput>
It is much easier to use \n than going to an ASCII table and looking up the character code. I always get the codes for \r and \n mixed up, so I end up looking them up every time I want to use them.
Tweet
Related Entries
- Auto-Linking Comments - June 24, 2005
- Regex to Replace Multiple Blank Lines with One - May 19, 2005
- Function to get Page Title from a URL - March 23, 2005
- Regular Expressions with ColdFusion - a Howto Guide - December 19, 2003
Trackbacks
Trackback Address: 289/9AFD3D996E5B507C00F007BF2B811C43
Comments
On 03/29/2005 at 7:47:38 AM EST Pete Jordan wrote:
1
FWIW it wasn't there in CF5; thanks for the heads up as we're in the middle of 5->7 migration, having skipped 6 altogether.
On 12/04/2005 at 12:23:37 AM EST Phillip Senn wrote:
2
Oh baby, baby.
On 01/31/2007 at 11:03:30 PM EST Dmitry wrote:
3
Thank you!!!! Your post save me an hour of aggrevation trying to remove the carriage return from cfhttp results.
Post a Comment
Recent Entries
- Writing Secure CFML cfObjective 2013 Slides
- Upgrading to Java 7 on Linux
- J2EE Sessions in CF10 Uses Secure Cookies
- Learn about ColdFusion Security at cfObjective 2013
- Session Loss and Session Fixation in ColdFusion
- FuseGuard 2.3 Released
- CKEditor Spell Checker Plugin
- Adobe Says Go Ahead and Upgrade your ColdFusion JVM


add to del.icio.us



