作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这个问题在这里已经有了答案:
How to remove more than one whitespace character from HTML?
(3 个回答)
7年前关闭。
我需要将字符串写入文本文件,但在此之前我需要确保该字符串不包含任何换行符、回车符或制表符。
我已经尝试过此代码进行测试。
<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#">
最佳答案
尝试:
<cfset str = "a#chr(10)#bc#chr(13)#def#chr(9)#fg">
<cfset cleanedStr = reReplace(str,"\s","","ALL")>
<cffile action="write" file="D:/project/test.txt" output="#cleanedStr#">
关于regex - 如何从 ColdFusion 中的字符串中删除换行符、回车符和制表符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25062204/
我是一名优秀的程序员,十分优秀!