将换行符替换为'\ n' [英] Replace break line with '\n'
本文介绍了将换行符替换为'\ n'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用\ n替换mysql数据库中的换行符的帮助. 如果我在MS Word中复制mysql文本和过去的内容,则有以下内容:
I need help for replacing line breaks in my mysql database with \n. If I copy mysql text and past in MS Word, I have this:
我需要将换行符替换为\ n.像这样:
I need to replace the break lines with \n. Like this:
对此有任何MySql命令以及一个PHP或Javascript函数吗?
There are any MySql command for this and one PHP or Javascript function?
谢谢.
推荐答案
在Php中,有一个名为nl2br
In Php there is a function named nl2br
echo nl2br("hello\nWorld");
结果是
hello<br/>World
在sql中,有一个名为REPLACE
In sql there is a function named REPLACE
UPDATE yourtable SET field=REPLACE(REPLACE(field, CHAR(13), ''), CHAR(10), '')
最后在javaScript中您也有replace
And Finally in javaScript you have replace
too
myString = myString.replace(/\r?\n/g, "");
祝你好运
这篇关于将换行符替换为'\ n'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文