Pre-recorded question

Question #8
In Javascript, how to remove carriage return from string?
Answer

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 Alphonsio 04/29/2020 at 05:55:05 PM
In JS, how to remove carriage return from string?
Answer by Alphonsio 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 Alphonsio 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.