title: Xml schema regex to not allow white spaces alone
body: <p>In xml, i have a tag say <code>&lt;membercode&gt;</code></p>
  
  <p>The regex pattern for the field currently is  <code>&lt;xs:pattern value="[a-zA-Z0-9\s]{1,3}" /&gt;</code></p>
  
  <p>The membercode  must accept values as follows:</p>
  
  <pre><code>1) "XY"  -&gt; pass
  
  2) "XY " -&gt; pass
  
  3) "   " -&gt; i need to have this failed. but it is getting passed.
  
  4) " XY " -&gt; need to be failed 
  </code></pre>
  
  <p>EDIT: Requirements:</p>
  
  <p>1) total allowed characters must be maximum 3.</p>
  
  <p>2) With in the allowed 3 chars, there can be spaces. ex: <code>"XY", "XY "," XY" , "X "</code> </p>
  
  <p>3) But if the total chars exceed 3 or if there is only spaces(no alphanumeric chars) then it should not be allowed. </p>
  
  <p>tried  whitespace collapse property, but in that case the maxlength is applied after the collapse is done.
  so values more than max length is also allowed.</p>
  
  <p>hence tried below things..</p>
  
  <pre><code>&lt;xs:pattern value="[a-zA-Z0-9]{1,3}[\s?]" /&gt;
  &lt;xs:pattern value="[a-zA-Z0-9]{1,3}|[a-zA-Z0-9\s?]{1,3}" /&gt;
  </code></pre>
  
  <p>but couldn't get hold on the correct solution.</p>
  
  <p>Please point me the correct approach for this..</p>
  
  <p>Many thanks for the suggestions!</p>