Remove extra spaces, line feed and carriage return without using regex

244 Views Asked by At

We currently generate an html and then clean up the whitepace (generated even after the CF admin setting)

<cfset Str = REReplace(Str, "[#Chr(9)##Chr(10)##Chr(13)#]", "", "all")>

It works, but in some of the html is huge and regex shows memory issues. How can I do it without using regex, with simple Replace function may be? Idea is, we can identify beforehand that this html is going to be bigger and parse that through simple Replace instead of regex?

1

There are 1 best solutions below

0
Daemach On

I've found Lucee's whitespace management to work quite well. Might be worth a look.

enter image description here