title: Firestore Regex Rule allow white space, but do not begin or end with one, and not all white spaces
body: <p>I am buidling a regex2 rule for a displayed_name on Firestore. What my rule should do:</p>
  <ol>
  <li>Allow alphanumeric, capital letters as well, the string length should be 3-16 chars</li>
  <li>Allow white spaces, but it should not be all white spaces</li>
  <li>Do not begin or end with a white space.</li>
  </ol>
  <p>This is my current rule. It satisfies the first requirement, but I am stuck with the next 2 requirements:</p>
  <pre><code>let string_rule = &quot;^[a-zA-Z0-9_-]{3,16}$&quot;;
  </code></pre>
  <p>I have tried adding another rule such <code>^[^\s]+(\s+[^\s]+)*$</code>, but it produced the errors of :</p>
  <pre><code>!  firestore.rules:29:30 - ERROR Missing a closing &quot;
  !  firestore.rules:29:30 - ERROR mismatched input 's' expecting {'&amp;&amp;', '.', '==', '&gt;', '&gt;=', '[', '&lt;', '&lt;=', '-', '%', '!=', '||', '+', ';', '/', '*', '?', 'in', 'is'}
  !  firestore.rules:29:34 - ERROR token recognition error at: '\'
  !  firestore.rules:29:38 - ERROR token recognition error at: '^'
  !  firestore.rules:29:39 - ERROR token recognition error at: '\'
  </code></pre>
  <p>When I simply modified my rule to <code>&quot;[^\s]&quot;</code>, it failed with the following error:</p>
  <pre><code>firestore.rules:29:29 - ERROR Missing a closing &quot;
  !  firestore.rules:29:29 - ERROR mismatched input 's' expecting {'&amp;&amp;', '.', '==', '&gt;', '&gt;=', '[', '&lt;', '&lt;=', '-', '%', '!=', '||', '+', ';', '/', '*', '?', 'in', 'is'}
  </code></pre>
  <p>I feel like I might have gotten the rule syntax for the white space wrong. But from the documentation of RE2 I read: <a href="https://github.com/google/re2/wiki/Syntax#perl" rel="nofollow noreferrer">https://github.com/google/re2/wiki/Syntax#perl</a>. <code>\s</code> is a Perl character class, and would allow white space, <code>\S</code> would not allow white space. What did I do wrong here, and what should my rule be to satisfy the requirments?</p>