i'd like to remove any whitespace surrounding a new line, from
Here is a new line. /n
New line.
to
Here is a new line./n
New line.
I've found various examples how to remove whitespaces, and how to remove new lines, but not how to replace a ' '+/n with a simple /n. I tried sth like the following but it didn't work:
paragraphs = paragraphs.replace(/(\r\n|\n|\r|' '+\n|' '+\r|\n+' '|\r+' ')/gm,'<br>');
UPDATE:
that's how i solved it: paragraphs = paragraphs.replace(/\r\n|\n|\r/gm,'\n'); // clears array of empty elements (double new lines) paragraphs = $.grep(paragraphs,function(n){ return(n) }); // clears text of all double whitespaces for (p=0;p
\and/chars are not interchangeable\doesn t make sense. I just edited my answer to make you a simplier regex proposal