title: How replace whitespaces (unicode to utf-8) with a regex C#
body: <p>I'm trying to do a replace regex in C #. The method that I'm trying to write replace some unicode character (spaces) by normal space in UTF-8.</p>
  
  <p>Let me explain with code. I'm not good writting regular expressions, culture information and regex. </p>
  
  <pre><code>    //This method replace white spaces in unicode by whitespaces UTF-8
      public static string cleanUnicodeSpaces(string value)
      {
          //This first pattern works but, remove other special characteres
          //For example: mark accents
          //string pattern = @"[^\u0000-\u007F]+"; 
          string cleaned = ""; 
          string pattern = @"[^\u0020\u0009\u000D]+"; //Unicode characters
          string replacement = ""; //Replace by UTF-8 space
          Regex regex = new Regex(pattern);
          cleaned = regex.Replace(value, replacement).Trim(); //Trim by quit spaces
          return cleaned;
      }
  </code></pre>
  
  <p><strong>Unicode spaces</strong></p>
  
  <ul>
  <li>HT:U+0009 = Character tabulation </li>
  <li>LF:U+000A = Line Feed</li>
  <li>CR:U+000D = Carriage Return</li>
  </ul>
  
  <p>What I doing wrong?</p>
  
  <p><strong>Source</strong> </p>
  
  <ol>
  <li>Unicode Characteres: <a href="https://unicode-table.com/en" rel="nofollow noreferrer">https://unicode-table.com/en</a></li>
  <li>White Spaces:<a href="https://en.wikipedia.org/wiki/Whitespace_character" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Whitespace_character</a> </li>
  <li>Regex: <a href="https://msdn.microsoft.com/es-es/library/system.text.regularexpressions.regex(v=vs.110).aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/es-es/library/system.text.regularexpressions.regex(v=vs.110).aspx</a></li>
  </ol>
  
  <p><em>SOLUTION</em>
  Thanks to @wiktor-stribiżew and @mathias-r-jessen, solution:</p>
  
  <pre><code> string pattern = @"[\u0020\u0009\u000D\u00A0]+";
   //I include \u00A0 for replace &amp;nbsp
  </code></pre>