 <p>This should work (though not recommended)</p> <pre><code>^(55[0-5]|5[0-4][0-9]|[1-4][0-9][0-9]|[1-9][0-9]|[5-9])$ </code></pre> <p><strong><a href="https://regex101.com/r/mX2eE9/3" rel="nofollow">Regex Demo</a></strong></p> <p><strong><a href="http://ideone.com/gM4waF" rel="nofollow">Proof of correctness</a></strong></p>