 <p>Pretty straightforward:</p> <pre><code>0[0-9]{3}(w000|n000|wd00|nd00)[a-z0-9]{7} </code></pre> <p>There are plenty of other ways you can represent this, but this should match the string you described.</p>