REFind and ReReplace support \r \n and \t
I noticed today that the regular expression functions in CF support the newline character
\n Chr(10), carriage return
\r Chr(13), and tab
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
\n mixed up, so I end up looking them up every time I want to use them.
- 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
- Travis CI Error when installing oraclejdk8
- Tuning Tomcat IIS Connectors worker.properties and server.xml
- Push Tomcat logs with the AWS CloudWatch Logs Agent
- Sending nginx access logs to CloudWatch Logs Agent
- Setup CloudWatch Logs Agent on Ubuntu 18.04 LTS
- Tomcat Virtual Directory Howto
- Communications link failure MySQL JDBC with TLS
- Redirect www and non https in IIS using web.config