Richard,


Here's what I do:


In my application.cfm file, I have a globally scoped variable called
CRLF like this:


<CFSET CRLF = chr(13) & chr(10) >


Then, in all my templates, whenever I need to take out a carriage
return, I just do the following (this example is changing it to HTML
line breaks):


<cfoutput>
#replacenocase(string,CRLF,"<br>","All")#
</cfoutput>


I use replacenocase as it seems to me their might be a tiny performance
benefit since it's not even
concerned about case (even though that wouldn't matter for special
characters anyway.


I believe you can also do:


replacenocase(string,chr(13)&chr(10),"all")


That should work too.

Hope this helps.


Dave
________________________________

From: Richard Crawford [mailto:[EMAIL PROTECTED]
Sent: Monday, June 07, 2004 4:24 PM
To: CF-Talk
Subject: Replacing special characters in a string

I have a set of strings that contain carriage returns.  I'd like to go
through and strip them out.  I figure the REPLACE function would do the
job but I'm not sure how to refer to the carriage returns.

INPUT STRING:

"I am a string with a
carriage return"

OUTPUT STRING:

"I am a string with a carriage return"

Any hints out there?

--
Richard S. Crawford
Programmer III,
UC Davis Extension Distance Learning Group (http://unexdlc.ucdavis.edu)
(916)327-7793 / [EMAIL PROTECTED]
________________________________
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to