title: Regex to prevent trailing spaces and extra spaces
body: <p>Right now I have a regex that prevents the user from typing any special characters. The only allowed characters are A through Z, 0 through 9 or spaces.</p>
  
  <p>I want to improve this regex to prevent the following:</p>
  
  <ol>
  <li>No leading/training spaces - If the user types one or more spaces before or after the entry, do not allow.</li>
  <li>No double-spaces - If the user types the space key more than once, do not allow.</li>
  </ol>
  
  <p>The Regex I have right now to prevent special characters is as follows and appears to work just fine, which is:</p>
  
  <pre><code>^[a-zA-Z0-9 ]+$
  </code></pre>
  
  <p>Following some other ideas, I tried all these options but they did not work:</p>
  
  <pre><code>^\A\s+[a-zA-Z0-9 ]+$\A\s+
  /s*^[a-zA-Z0-9 ]+$/s*
  </code></pre>
  
  <p>Could I get a helping hand with this code? Again, I just want letters A-Z, numbers 0-9, and no leading or trailing spaces.</p>
  
  <p>Thanks.</p>