Split string in JavaScript and detect line break

前端 未结 7 1178
情书的邮戳
情书的邮戳 2020-12-24 04:55

I have a small function I found that takes a string from a textarea and then puts it into a canvas element and wraps the text when the line gets to

7条回答
  •  清歌不尽
    2020-12-24 05:15

    Split string in JavaScript

    var array = str.match(/[^\r\n]+/g);
    

    OR

    var array = str.split(/\r?\n/);
    

提交回复
热议问题