title: Swift: Validate Username Input
body: <p>Working on a Swift app and I have a form filled by user and I would like the user to select their own username. The only constraints I want on the username are:</p>
  
  <blockquote>
    <ul>
    <li>No special characters (e.g. @,#,$,%,&amp;,*,(,),^,&lt;,>,!,±)</li>
    <li>Only letters, underscores and numbers allowed</li>
    <li>Length should be 18 characters max and 7 characters minimum</li>
    </ul>
  </blockquote>
  
  <p>Where can I find a function that validates an input string (function parameter) and return true or false based on above criteria? I am not very well versed in regular expressions.</p>