Question #8   Submitted by Answiki on 04/29/2020 at 05:51:12 PM UTC

In Javascript, how to remove carriage return from string?

Answer   Submitted by Answiki on 04/29/2020 at 05:54:48 PM UTC

In JavaScript, to remove carriage return from string, use the following regex str.replace(/[\n\r]/g, ''); as on the following example :

var str="abc \n def \r ghi";

// Should change str for "abc  def  ghi"
str.replace(/[\n\r]/g, '');


3 events in history
Question by Answiki 04/29/2020 at 05:55:05 PM
In JS, how to remove carriage return from string?
Answer by Answiki on 04/29/2020 at 05:54:48 PM

In JavaScript, to remove carriage return from string, use the following regex str.replace(/[\n\r]/g, ''); as on the following example :

var str="abc \n def \r ghi";

// Should change str for "abc  def  ghi"
str.replace(/[\n\r]/g, '');


Question by Answiki 04/29/2020 at 05:51:12 PM
In Javascript, how to remove carriage return from string?
# ID Query URL Count

Icons proudly provided by Friconix.