title: UTF 8 String remove all invisible characters except newline
body: <p>I'm using the following regex to remove all invisible characters from an UTF-8 string:</p>
  
  <pre><code>$string = preg_replace('/\p{C}+/u', '', $string);
  </code></pre>
  
  <p>This works fine, but how do I alter it so that it removes all invisible characters EXCEPT newlines? I tried some stuff using [^\n] etc. but it doesn't work.</p>
  
  <p>Thanks for helping out!</p>
  
  <p>Edit: newline character is '\n'</p>