title: Regular expression any character but a white space
body: <p>I'm creating a password validator which takes any character but whitespaces and with at least 6 characters.</p>
  
  <p>After searching the best I came up is this is this example:
  <a href="https://stackoverflow.com/questions/3020760/what-is-the-regular-expression-for-matching-that-contains-no-white-space-in-betwe">What is the regular expression for matching that contains no white space in between text?</a></p>
  
  <p>It disallows any spaces inbetween but does allow starting and ending with a space. I want to disallow any space in the string passed.</p>
  
  <p>I tried this but it doesn't work:</p>
  
  <pre><code>if (preg_match("/^[^\s]+[\S+][^\s]{6}$/", $string)) {
    return true;
  } else {
    return false;
  }
  </code></pre>
  
  <p>Thanks.</p>