[英]in js, how do i replace add \n (not a new line marker) as a string to end of each line in a textarea
ok so ill try to be clear. 好吧,病了,要弄清楚。
I have a textarea and it will have multiple lines of text and at the end of each line i want to add \\n but the replace function just adds a new line. 我有一个textarea,它将有多行文本,每行的末尾我想添加\\ n,但是replace函数只是添加了一行。 I am then going to put the result into a different textarea after the string has been modified.
然后,在修改字符串之后,我将结果放入另一个textarea中。
i have tried a variety of methods but cant seem to get it to work 我尝试了多种方法,但似乎无法使其正常工作
example of my current stage 我当前阶段的例子
var my_text=$("textarea[name=text_area]").val();
my_text=my_text.replace(/\n/g,'["\n"]\n');
my_text=$("textarea[name=modifiedtext_area]")
i want the textbox content to go from 我希望文本框内容来自
fgdf
g
sdfg
asdff
to the below in the new textarea 到下面的新文本区域
fgdf\n
g\n
sdfg\n
asdff\n
如果要显示实际文本\\n
,则必须转义斜杠\\\\n
my_text=my_text.replace(/\n/g,"\\n\n");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.