Reputation: 949
I am receiving a comments from service. If I get this comment "hello world" it is printing as it is but when I receive Comments like this "hello
world" then I am receiving nothing I write a function for it but it also doesn't work
function NextLineFix(Call) {
return Call.replace("\n", '<br>');
}
Can any body help please....!
Upvotes: 0
Views: 106
Reputation: 8766
try this:
function NextLineFix(Call) {
return Call.replace(/[\r\n]/gi, '<br/>');
}
Upvotes: 2
Reputation: 328
Perhaps you also have carriage return characters in the string ('\r')? Does this work better for your issue:
Call.replace("\r", "").replace("\n", "<br/>") ?
Upvotes: 2
Reputation: 387
Try it with \r\n instead of \n and then do the replace , see if that helps
Upvotes: 0