Regular Expression with letter
<p>I need to match things that format something along the lines of 
657432-76,   54678-01,   54364<strong>A</strong>-12</p>

<p>I got <code>(r'^\d{6}-\d{2}$')</code>
and   <code>(r'^\d{5}-\d{2}$')</code>
but how do you get the letter?</p>

<p>thanks!!</p>

<p>If you want a single regex to match the 3rd pattern you can use a regex like this:</p>

<pre><code>(?i)(r'^\d{5}[a-z]-\d{2}$')
</code></pre>

<p><strong><a href="https://regex101.com/r/uA0bK2/1" rel="nofollow">Working demo</a></strong></p>

<p>However, if you want to have a single regex for all of them, you might find useful:</p>

<pre><code>(?i)(r'^\d{5-6}[a-z]?-\d{2}$')
</code></pre>

<p>Keep in mind that this will allow: <code>657432A-76</code> but if you just want 5 digits only with the letter, then you could use:</p>

<pre><code>(?i)(r'^\d{5}(?:\d?|[a-z])-\d{2}$')
</code></pre>

python regex format expression