JavaScript Newline Character

后端 未结 4 1472
灰色年华
灰色年华 2020-12-29 04:10

From this question, this ...

lines = foo.value.split(/\\r\\n|\\r|\\n/);

is one way to split a string, but how do I join it back with newlin

4条回答
  •  再見小時候
    2020-12-29 04:31

    You can use the Array object's join method to glue together array elements into a string:

    lines.join("\r\n");
    

    In CSS: remember to use

    white-space: pre;
    

提交回复
热议问题