如何用< br /&gt ;?替换CR + LF [英] How to replace CR+LF with <br />?

查看:453
本文介绍了如何用< br /&gt ;?替换CR + LF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:

用户提交带有< 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

这篇关于如何用&lt; br /&gt ;?替换CR + LF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆