title: Remove all whitespace from C# string with regex
body: <p>I am building a string of last names separated by hyphens. Sometimes a whitespace gets caught in there. I need to remove all whitespace from end result.</p>
  
  <p>Sample string to work on:</p>
  
  <blockquote>
    <p>Anderson -Reed-Smith</p>
  </blockquote>
  
  <p>It needs to end up as (no space after Anderson):</p>
  
  <blockquote>
    <p>Anderson-Reed-Smith</p>
  </blockquote>
  
  <p>The last name string is in a string variable, LastName.</p>
  
  <p>I am using a regular expression:</p>
  
  <pre><code>Regex.Replace(LastName, @"[\s+]", "");
  </code></pre>
  
  <p>The result of this is:</p>
  
  <blockquote>
    <p>Anderson -Reed-Smith.</p>
  </blockquote>
  
  <p>I also tried:</p>
  
  <pre><code>Regex.Replace(LastName, @"\s+", "");
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Regex.Replace(LastName, @"\s", "");
  </code></pre>
  
  <p>What am I doing wrong?</p>