Regex for capital letters followed be a space folllowed by numbers 'ABC 123' or 'BLZ 420'
<p>So I have this script that identifies <code>ABC-123</code></p>

<pre><code>e = r'[A-Z]+-\d+'
</code></pre>

<p>shouldn't this identify <code>ABC 123</code></p>

<pre><code>e = r'[A-Z]+/s\d+'
</code></pre>

<p>Or am I missing something blindingly obvious. Thanks. This is in Python as well. </p>

<p>You have the wrong slash, you need a backslash:</p>

<pre><code>e = r'[A-Z]+\s\d+'
</code></pre>

<p><code>/s</code> will match <code>/</code> followed by a <code>s</code> literally, whereas <code>\s</code> is a Regex token that indicates a whitespace.</p>

python regex