Regex to Replace Multiple Blank Lines with One
I'm working on a function to strip HTML, but preserve things like paragraph spacing. In removing HTML tags, sometimes you end up with lots of blank lines... Here's a quick regular expression to convert multiple blank lines with just one
<cfset content = ReReplace(content, "[\r\n]+", "#Chr(10)#", "ALL")>
Like this? Follow me ↯Tweet Follow @pfreitag
Regex to Replace Multiple Blank Lines with One was first published on May 19, 2005.
If you like reading about regex, cfml, rereplace, or html then you might also like:
- Auto-Linking Comments
- CFParam for Integer or Empty String
- Widon't and Widows
- Textile for ColdFusion
- Cheat Sheet Roundup - Over 30 Cheatsheets for developers
- REFind and ReReplace support \r \n and \t
- Function to get Page Title from a URL
- Regular Expressions with ColdFusion - a Howto Guide
The FuseGuard Web Application Firewall for ColdFusion & CFML is a high performance, customizable engine that blocks various attacks against your ColdFusion applications.