I have a text in a textarea and I read it out using the .value attribute.
Now I would like to remove all linebreaks (the character that is produced when you press
You can use \n in a regex for newlines, and \r for carriage returns.
\n
\r
var str2 = str.replace(/\n|\r/g, "");
Different operating systems use different line endings, with varying mixtures of \n and \r. This regex will replace them all.