title: Check for special characters in a string using regex in java
body: <p>How to check for special chars in a string? I am checking for just empty spaces using regex but when i enter special chars it's considering them as space. Below is my code</p>
  
  <pre><code>  private boolean emptySpacecheck(String msg){
  
      return msg.matches(".*\\w.*");
  }
  </code></pre>
  
  <p>How to check for special chars?</p>