Remove Return Characters From String
Remove return characters from a string. This is useful for sanitizing text which was input by a user.
textcomment = textcomment.replace(/(\r\n|\n|\r)/gm, " ");
Example:
Javascript
textcomment = "This\
text should\
have all the return characters removed.";
textcomment = textcomment.replace(/(\r\n|\n|\r)/gm, " ");
Produces the result:
textcomment == This text should have all the return characters removed.
(and it does :)