title: Is it possible to match different specific length using RegExp in JavaScript?
body: <p>I know that with JS RegExp I can match:</p>
  
  <ul>
  <li>Exact length; <code>/^[a-zA-Z]{7}$/</code> </li>
  <li>A length range; <code>/^[a-zA-Z]{3,7}$/</code> </li>
  <li>A minimum length; <code>/^[a-zA-Z]{3,}$/</code></li>
  </ul>
  
  <p>What if I wanna match varying specific lengths? Something like: <code>/^[a-zA-Z]{2|4|6}$/</code> meaning that the string must have either length of 2, 4 or 6 characters. Can I do it using JavaScript's RegExp?</p>
  
  <p>I tried googling but couldn't find a way to search for this specific case, I always end up finding how to match length ranges.</p>
  
  <p><strong>Scenario</strong>: I currently have this <code>if</code> statement that I would like to make shorter: </p>
  
  <pre><code>if(typeof ean !== 'string' || !/^\d+$/.test(ean) || [8, 12, 13, 14].indexOf(ean.length) === -1) {
      return false;
  }
  </code></pre>