title: Regex to remove spaces
body: <p>How to write a regex to remove spaces in Java?</p>
  
  <p>For example</p>
  
  <pre><code>Input  : "         "
  Output : ""
  ---------------------
  Input  : " "
  Output : ""
  </code></pre>
  
  <p>Note that tabs and new lines should not be removed. Only spaces should be removed.</p>
  
  <p><strong>Edit :</strong></p>
  
  <p>How do we make a check ?</p>
  
  <p>For example how to check in an <em>if</em> statement that  a String contains only spaces (any number of them)</p>
  
  <pre><code>  if(&lt;statement&gt;)
    {
                //inside statement
    }
  </code></pre>
  
  <p>For   </p>
  
  <pre><code>   input = "                   "  or input = "    "
  </code></pre>
  
  <p>The control should should go inside <em>if</em> statement.</p>