如何用< br /> ;?替换CR + LF [英] How to replace CR+LF with <br />?
问题描述
例如:
用户提交带有< textarea name =mytextcols =35rows = 2>< / textarea>
,然后按 ENTER 如何用< br />
A user submits a form with a <textarea name="mytext" cols="35" rows="2"></textarea>
and presses ENTER within it. How would I replace the CR-LF with a <br />
?
推荐答案
CF有一个称为ParagraphFormat()的函数:
CF has a function for this called ParagraphFormat():
<cfset form.userText = paragraphFormat(form.usertext)/>
从帮助文档 -
字符中的字符:
- 包含空格的单个换行符(CR / LF序列)
- 带有HTML段落标签的换行符(
< p>
)
- Single newline characters (CR/LF sequences) with spaces
- Double newline characters with HTML paragraph tags (
<p>
)
比您想要的更多,因为它也会查找双重换行符并添加< p>
和< / p>
标签。
It may do more than you want in that it also looks for double line breaks and adds <p>
and </p>
tags.
Ben还有一个名为paragraph2的增强版本(UDF),很容易修改,想。以下是链接:
Ben also has an enhanced version (a UDF) called paragraph2 that would be easy to modify to get the exact affect you want. Here's the link:
http://www.cflib.org/udf / ParagraphFormat2
这篇关于如何用< br /> ;?替换CR + LF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!