title: How to check if a string is certain amount of characters and contains (or doesn't contain) certain characters? C++
body: <p>Let's say I have two strings (string1, string2) based off of user inputs. I want  <strong>string1</strong> to be <strong>at least 5 characters</strong>, <strong>at most 10 characters</strong>, and only allowed to contain the following:</p>
  
  <ol>
  <li>Upper case letters</li>
  <li>Lower case letters</li>
  <li>Numbers (0-9)</li>
  </ol>
  
  <p>Otherwise, the user will be prompted to keep entering strings until the requirements are met.</p>
  
  <pre><code>while(len(string1)&lt;5 or len(string1)&gt;10) {
      if(len(string1) &gt; 10) {
          cout &lt;&lt; "Please enter a string that is less than 10 characters: ";
          cin &gt;&gt; input;
      } else if(len(string) &lt; 5) {
          cout &lt;&lt; "Please enter a string that is more than 5 characters: ";
          cin &gt;&gt; input;
      } else {
          cout &lt;&lt; "Please enter a string with legal characters (uppercase/lowercase letters and numbers): ";
          cin &gt;&gt; input;
      }
  </code></pre>
  
  <p>How would I check if string1 only contains uppercase letters, lowercase letters, and numbers? Would I use the following in some sort of way?...</p>
  
  <pre><code>string legalChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";   
  string1.find_first_not_of(legalChars)
  </code></pre>
  
  <p>As for string2, I want the user input to be <strong>at least 6 characters long</strong> and to contain <strong>at least one non-letter character</strong>. </p>
  
  <pre><code>while(len(string2)&lt;6) {
      if(len(string2)&lt;6) {
          cout &lt;&lt; "Please enter a string that is at least 6 characters long: ";
          cin &gt;&gt; input2;
      } 
  }
  </code></pre>
  
  <p>How would I check for non-letter characters in string2? How should I approach this problem?</p>