[removed] how to use a regular expression to remove blank lines from a string?

后端 未结 4 1547
走了就别回头了
走了就别回头了 2020-12-01 03:48

I need to use JavaScript to remove blank lines in a HTML text box. The blank lines can be at anywhere in the textarea element. A blank line can be just a return

4条回答
  •  醉话见心
    2020-12-01 04:02

    This should do the trick i think:

    var el = document.getElementsByName("nameOfTextBox")[0];
    el.value.replace(/(\r\n|\n|\r)/gm, "");
    

    EDIT: Removes three types of line breaks.

提交回复
热议问题