我需要将字符串写入文本文件,但在此之前我需要确保字符串不包含任何换行符、回车符或制表符。
我已经尝试过此代码进行测试。
<cfset str = "a#chr(10)#bc#chr(13)#def#chr(9)#fg">
<cfset cleanedStr = reReplace(str,"#chr(13)##chr(10)#","","ALL")>
<cfset cleanedStr = reReplace(str,"#chr(10)#","","ALL")>
<cfset cleanedStr = reReplace(str,"#chr(13)#","","ALL")>
<cfset cleanedStr = reReplace(str,"#chr(9)#","","ALL")>
<cffile action="write" file="D:/projects/test.txt" output="#cleanedStr#">
但是当我在 Eclipse 中打开文件时,它仍然显示换行符和回车符。
那么删除这些字符的正确方法是什么?